HtmlTableRowCollection.RemoveAt Method
Removes the HtmlTableRow at the specified index from the HtmlTableRowCollection.
[Visual Basic] Public Sub RemoveAt( _ ByVal index As Integer _ ) [C#] public void RemoveAt( int index ); [C++] public: void RemoveAt( int index ); [JScript] public function RemoveAt( index : int );
Parameters
- index
- The index of the HtmlTableRow to remove from the HtmlTableRowCollection.
Exceptions
| Exception Type | Condition |
|---|---|
| ArgumentOutOfRangeException | The specified index is outside the range of index values in the collection. |
Remarks
Use this method to remove the HtmlTableRow at the specified index from the HtmlTableRowCollection. The index number is zero-based. Therefore, the first item in the collection has an index value of 0.
Note If you specify an index that is outside the range of index values, an exception is raised.
Example
[Visual Basic, C#, JScript] The following example demonstrates how to use the RemoveAt method to remove the item at the specified index from the HtmlTableRowCollection. This example removes 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. Table1.Rows.RemoveAt(0) 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. Table1.Rows.RemoveAt(0); } </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. Table1.Rows.RemoveAt(0); } </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
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 | Remove | Rows | HtmlTableRow