[C#]
<%@ Page Language="C#" AutoEventWireup="True" %><html>
<script runat="server" >
void Page_Load(Object sender, EventArgs e)
{ // Create the HtmlTable control.
HtmlTable table = new HtmlTable();
table.Border = 1;
table.CellPadding = 3; // Populate the HtmlTable control.
// Create the rows of the table.
for(int rowcount=0; rowcount<5; rowcount++)
{
HtmlTableRow row = new HtmlTableRow();
// Create the cells of a row.
for(int cellcount=0; cellcount<4; cellcount++)
{
HtmlTableCell cell; // Create table header cells for first row. ???我理解为:为第一行创表标头,与下面的"th"有什么关系?
if(rowcount <= 0)
{
cell = new HtmlTableCell("th"); ???为什么要这样做,什么意思
}
else
{
cell = new HtmlTableCell();
} // Create the text for the cell.
cell.Controls.Add(new LiteralControl(
"row " + rowcount.ToString() + ", " +
"column " + cellcount.ToString())); // Add the cell to the Cells collection of a row.
row.Cells.Add(cell);
} // Add the row to the Rows collection of the table.
table.Rows.Add(row);
}
// Add the control to the Controls collection of the
// PlaceHolder control.
Place.Controls.Clear();
Place.Controls.Add(table);
}
</script>
<body> <form runat="server">
<h3> HtmlTable Example </h3>
<asp:PlaceHolder id="Place" runat="server"/>
</form></body>
</html>
<%@ Page Language="C#" AutoEventWireup="True" %><html>
<script runat="server" >
void Page_Load(Object sender, EventArgs e)
{ // Create the HtmlTable control.
HtmlTable table = new HtmlTable();
table.Border = 1;
table.CellPadding = 3; // Populate the HtmlTable control.
// Create the rows of the table.
for(int rowcount=0; rowcount<5; rowcount++)
{
HtmlTableRow row = new HtmlTableRow();
// Create the cells of a row.
for(int cellcount=0; cellcount<4; cellcount++)
{
HtmlTableCell cell; // Create table header cells for first row. ???我理解为:为第一行创表标头,与下面的"th"有什么关系?
if(rowcount <= 0)
{
cell = new HtmlTableCell("th"); ???为什么要这样做,什么意思
}
else
{
cell = new HtmlTableCell();
} // Create the text for the cell.
cell.Controls.Add(new LiteralControl(
"row " + rowcount.ToString() + ", " +
"column " + cellcount.ToString())); // Add the cell to the Cells collection of a row.
row.Cells.Add(cell);
} // Add the row to the Rows collection of the table.
table.Rows.Add(row);
}
// Add the control to the Controls collection of the
// PlaceHolder control.
Place.Controls.Clear();
Place.Controls.Add(table);
}
</script>
<body> <form runat="server">
<h3> HtmlTable Example </h3>
<asp:PlaceHolder id="Place" runat="server"/>
</form></body>
</html>
<tr>
<th>表头</th>
</tr>
<tr>
<td>内容</td>