HtmlTableBodySection Class
[Note: This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.] Namespace: System.Web.UI.HtmlControls
Assembly: System.Web (in System.Web.dll)
Represents the tbody element in an HtmlTable control.
Assembly: System.Web (in System.Web.dll)
Use the HtmlTableBodySection control to programmatically control the tbody child element of a table element on the server.
The rows of the HtmlTableBodySection control are stored in the Rows property of the control. This allows you to programmatically access the individual rows of the body element
The following example shows how to programmatically access the HtmlTableBodySection of a table. The background color of the body section is changed and row is added during postback.
<%@ 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"> protected void Button1_Click(object sender, EventArgs e) { if (((Button)sender).Text == "Submit") { // Set a property of the HtmlTableBodySection. TheBody.BgColor = "gray"; // Add a new row to the HtmlTableBodyRowControlCollection. HtmlTableRow tr = new HtmlTableRow(); HtmlTableCell tc = new HtmlTableCell(); tc.InnerText = DateTime.Now.ToString(); tc.ColSpan = 2; tr.Cells.Add(tc); TheBody.Rows.Add(tr); // Set the text of a Button control in the HtmlTableFooterSection. Button1.Text = "Clear"; // Set the text of a column header. Column1Header.InnerText = "New Header"; } else { // Reset values. TheBody.BgColor = "white"; Button1.Text = "Submit"; Column1Header.InnerText = "Column1 Header"; } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>HtmlTable Sections</title> </head> <body> <form id="form1" runat="server"> <div> <table id="Table1" runat="server" style="border: solid 1px blue" > <thead> <tr> <td id="Column1Header">Column1 Header</td> <td>Column2 Header</td> </tr> </thead> <tbody id="TheBody"> <tr> <td id="BodyCell1">Table Cell 1.</td> <td id="BodyCell2">Table Cell 2.</td> </tr> </tbody> <tfoot > <tr > <td colspan="2" style="text-align:right" > <asp:Button ID="Button1" runat="server" Text="Submit" onclick="Button1_Click" /> </td> </tr> </tfoot> </table> </div> </form> </body> </html>
- AspNetHostingPermission
for operating in a hosted environment. Demand value: LinkDemand; Permission value: Minimal.
- AspNetHostingPermission
for operating in a hosted environment. Demand value: InheritanceDemand; Permission value: Minimal.
System..::Object
System.Web.UI..::Control
System.Web.UI.HtmlControls..::HtmlControl
System.Web.UI.HtmlControls..::HtmlContainerControl
System.Web.UI.HtmlControls..::HtmlTableRow
System.Web.UI.HtmlControls..::HtmlTableBodySection
System.Web.UI..::Control
System.Web.UI.HtmlControls..::HtmlControl
System.Web.UI.HtmlControls..::HtmlContainerControl
System.Web.UI.HtmlControls..::HtmlTableRow
System.Web.UI.HtmlControls..::HtmlTableBodySection