October 4, 2011

ASP.NET Table Server Control



<asp:TableID="Table1"runat="server">
<asp:TableRowRunat="server"Font-Bold="True"
ForeColor="Black"BackColor="Silver">
<asp:TableHeaderCell>FirstName</asp:TableHeaderCell>
<asp:TableHeaderCell>LastName</asp:TableHeaderCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>Bill</asp:TableCell>
<asp:TableCell>Evjen</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>Devin</asp:TableCell>
<asp:TableCell>Rader</asp:TableCell>
</asp:TableRow>
</asp:Table>



Below code snippet is used to add a row dynamically in the Table Server Control


C#
protected void Page_Load(object sender,EventArgs e)
{
TableRowtr=new TableRow();
TableCell name=new TableCell();
name.Text="Test3";
tr.Cells.Add(name);
TableCell lname=new TableCell();
lname.Text="Test4";
tr.Cells.Add(lname);
Table1.Rows.Add(tr);
}

No comments:

Post a Comment