Export (0) Print
Expand All

HtmlTableCellCollection.Remove Method

Removes the specified HtmlTableCell object from the HtmlTableCellCollection collection.

Namespace: System.Web.UI.HtmlControls
Assembly: System.Web (in system.web.dll)

public void Remove (
	HtmlTableCell cell
)
public void Remove (
	HtmlTableCell cell
)
public function Remove (
	cell : HtmlTableCell
)

Parameters

cell

The HtmlTableCell to remove from the HtmlTableCellCollection.

Use this method to remove the specified HtmlTableCell object from the HtmlTableCellCollection collection.

NoteNote

If you specify an HtmlTableCell object that does not exist in the HtmlTableCellCollection collection, no item is removed from the collection.

The following code example demonstrates how to use the Remove method to remove the specified cell of a table, represented by an HtmlTableCell object, from the HtmlTableCellCollection collection. This example removes the cells from the first column of the HtmlTable control.

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

<script runat="server">

  void Button_Click(Object sender, EventArgs e)
  {

    // Iterate through the rows of the table.
    for (int i = 0; i <= Table1.Rows.Count - 1; i++)
    {

      // Remove the cells from the first column.
      HtmlTableCell cell = Table1.Rows[i].Cells[0];
      Table1.Rows[i].Cells.Remove(cell);

    }

  }

</script>

<html>
<head>
   <title>HtmlTableCellCollection Example</title>
</head>
<body>

   <form runat="server">

      <h3>HtmlTableCellCollection 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 Column from Table"
             onserverclick="Button_Click" 
             runat="server"/>

   </form>

</body>
</html>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2015 Microsoft