Export (0) Print
Expand All

HtmlTableRowCollection.Remove Method

Removes the specified HtmlTableRow from the HtmlTableRowCollection.

[Visual Basic]
Public Sub Remove( _
   ByVal row As HtmlTableRow _
)
[C#]
public void Remove(
 HtmlTableRow row
);
[C++]
public: void Remove(
 HtmlTableRow* row
);
[JScript]
public function Remove(
   row : HtmlTableRow
);

Parameters

row
The HtmlTableRow to remove from the HtmlTableRowCollection.

Remarks

Use this method to remove the specified HtmlTableRow from the HtmlTableRowCollection.

Note   If you specify an HtmlTableRow that does not exist in the HtmlTableRowCollection, no item is removed from the collection.

Example

[Visual Basic, C#, JScript] The following example demonstrates how to use the Remove method to remove the specified row from a table, represented by a HtmlTableRow, from the HtmlTableRowCollection. This example removes the cells from the first row of the HtmlTable control.

[Visual Basic] 
<%@ Page Language="VB" AutoEventWireup="True" %>

<html>
<head>

   <script runat="server">

      Sub Button_Click(sender As Object, e As EventArgs) 
 
         ' Remove the first row from the table.
         Dim row As HtmlTableRow = Table1.Rows(0)
         Table1.Rows.Remove(row)

      End Sub

   </script>

</head>
<body>

   <form runat="server">

      <h3>HtmlTableRowCollection Example</h3>

      <table id="Table1" 
             Border="1" 
             BorderColor="black" 
             runat="server">

         <tr>
            <td>
               Cell 1
            </td>
            <td>
               Cell 2
            </td>
         </tr>
         <tr>
            <td>
               Cell 3
            </td>
            <td>
               Cell 4
            </td>
         </tr>

      </table>

      <br><br>
  
      <input type="button" 
             value="Remove First Row from Table"
             OnServerClick = "Button_Click" 
             runat="server"/>

   </form>

</body>
</html>

[C#] 
<%@ Page Language="C#" AutoEventWireup="True" %>

<html>
<head>

   <script runat="server">

      void Button_Click(Object sender, EventArgs e) 
      {
 
         // Remove the first row from the table.
         HtmlTableRow row = Table1.Rows[0];
         Table1.Rows.Remove(row);

      }

   </script>

</head>
<body>

   <form runat="server">

      <h3>HtmlTableRowCollection Example</h3>

      <table id="Table1" 
             Border="1" 
             BorderColor="black" 
             runat="server">

         <tr>
            <td>
               Cell 1
            </td>
            <td>
               Cell 2
            </td>
         </tr>
         <tr>
            <td>
               Cell 3
            </td>
            <td>
               Cell 4
            </td>
         </tr>

      </table>

      <br><br>
  
      <input type="button" 
             value="Remove First Row from Table"
             OnServerClick = "Button_Click" 
             runat="server"/>

   </form>

</body>
</html>

[JScript] 
<%@ Page Language="JScript" AutoEventWireup="True" %>

<html>
<head>

   <script runat="server">

      function Button_Click(sender, e : EventArgs) 
      {
 
         // Remove the first row from the table.
         var row : HtmlTableRow = Table1.Rows[0];
         Table1.Rows.Remove(row);

      }

   </script>

</head>
<body>

   <form runat="server">

      <h3>HtmlTableRowCollection Example</h3>

      <table id="Table1" 
             Border="1" 
             BorderColor="black" 
             runat="server">

         <tr>
            <td>
               Cell 1
            </td>
            <td>
               Cell 2
            </td>
         </tr>
         <tr>
            <td>
               Cell 3
            </td>
            <td>
               Cell 4
            </td>
         </tr>

      </table>

      <br><br>
  
      <input type="button" 
             value="Remove First Row from Table"
             OnServerClick = "Button_Click" 
             runat="server"/>

   </form>

</body>
</html>

[C++] No example is available for C++. To view a Visual Basic, C#, or JScript example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

HtmlTableRowCollection Class | HtmlTableRowCollection Members | System.Web.UI.HtmlControls Namespace | RemoveAt | Rows | HtmlTableRow

Show:
© 2014 Microsoft