TableRowCollection.Remove Method (TableRow)
.NET Framework (current version)
Removes the specified TableRow from the TableRowCollection.
Assembly: System.Web (in System.Web.dll)
Parameters
- row
-
Type:
System.Web.UI.WebControls.TableRow
The TableRow object to remove from the TableRowCollection.
Use this method to remove the specified TableRow from a TableRowCollection.
The following example demonstrates how to use the Remove method to remove a row from the table. Note that in the example, the Rows property of the Table is an instance of the TableRowCollection class.
<%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> void Page_Load(Object sender, EventArgs e) { // Generate rows and cells. int numRows = 5; int numCells = 6; int counter = 1; for (int rowNum = 0; rowNum < numRows; rowNum++) { TableRow rw = new TableRow(); for (int cellNum = 0; cellNum < numCells; cellNum++) { TableCell cel = new TableCell(); cel.Text = counter.ToString(); rw.Cells.Add(cel); counter++; } Table1.Rows.Add(rw); Table1.GridLines = GridLines.Both; Table1.CellPadding = 4; Table1.CellSpacing = 0; } } void Button_Click(object sender, EventArgs e) { TableRow rw = Table1.Rows[2]; Table1.Rows.Remove(rw); } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>TableCellCollection Example</title> </head> <body> <form id="form1" runat="server"> <div> <h3>TableCellCollection Example</h3> <asp:Table id="Table1" runat="server"/> <br /> <br /> <asp:Button id="Button1" Text="Remove middle row" OnClick="Button_Click" runat="server"/> </div> </form> </body> </html>
.NET Framework
Available since 1.1
Available since 1.1
Show: