Reputation: 2958
I am adding table in code behind file. and i want to add tag in that.
<table id="tbl" runat="server">
<tr>
<th>test</th>
<td>
</td>
</tr>
</table>
I dont know how to add through code.
So can any one tell me how to add tag?
Upvotes: 3
Views: 8356
Reputation: 63
Dim tr As New HtmlTableRow
tr.Cells.Add(New HtmlTableCell("th"))
yourtable.Rows.Add(tr)
Upvotes: 1
Reputation: 2053
Table t = new Table();
TableHeaderRow th = new TableHeaderRow();
th.Controls.Add(new LiteralControl("test"));
t.Controls.Add(th);
containerControlForTheTable.Controls.Add(t);
Upvotes: 3
Reputation: 17804
HtmlTable t = tbl; //just to make it clear your table is an HtmlTable
tbl.Rows[0].Cells.Add(new HtmlTableCell("th")); //adds an emtpy cell to the first row with th tagname
Upvotes: 5