Search
Author
ASP.NET Tutorials
Author
Sheo Narayan
Advertisements


Winners

Win Prizes

Social Presence
Like us on Facebook

Silverlight Tutorials | Report a Bug in the Tutorial
asp:Table control
Table control is used to structure a web pages. In other words to divide a page into several rows and colums to arrange the information or images.
 
Table control is used to structure a web pages. In other words to divide a page into several rows and colums to arrange the information or images. When it is rendered on the page, it is implemented through <table> HTML tag.

Its properties like BackColor, ForeColor, BorderColor, BorderStyle, BorderWidth, Height etc. are implemented through style properites of <table> tag.

We can simply use HTML <table> control instead of using asp:Table control. However many of one benefits of using asp:Table control is we can dynamically add rows or columns at the runtime or change the appearance of the table.
You can skip ID property of the TableRow or TableCell, however it is advisable to write these property otherwise you will not be able to play with these controls.

Following are some important properties that are very useful.
BackImageUrl Used to Set background image of the table
Caption Used to write the caption of the table.
DEMO : Table Show Source Code
Demo of asp:Table control
Row 1 - Cell 1 Row 1 - Cell 2
Row 2 - Cell 1 Row 2 - Cell 2
Change Table Back Color
    <asp:Table ID="Table2" runat="Server" CellPadding="2" CellSpacing="1" 
        BorderColor="CadetBlue" Caption="Demo of asp:Table control" BorderWidth="1" BorderStyle="Dashed">
            <asp:TableRow ID="TableRow2" runat="Server" BorderWidth="1">
                <asp:TableCell ID="TableCell4" runat="Server" BorderWidth="1">
                    Row 1 - Cell 1
                </asp:TableCell>
                <asp:TableCell ID="TableCell5" runat="Server">
                    Row 1 - Cell 2
                </asp:TableCell>
            </asp:TableRow>
            <asp:TableRow ID="TableRow3" runat="Server">
                <asp:TableCell ID="TableCell6" runat="Server">
                    Row 2 - Cell 1
                </asp:TableCell>
                <asp:TableCell ID="TableCell7" runat="Server">
                    Row 2 - Cell 2
                </asp:TableCell>
            </asp:TableRow>
        </asp:Table>