search this blog [2700+ asp.net c# examples]

Loading...

ASP.NET Table Control Example

asp.net Table: how to use
Table.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Table.aspx.cs" Inherits="Table" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>asp.net Table: how to use</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:Navy">Table: how to use</h2>
        <asp:Table ID="Table1" runat="server">
            <asp:TableHeaderRow BackColor="Crimson">
                <asp:TableHeaderCell>Color</asp:TableHeaderCell>
                <asp:TableHeaderCell>Value</asp:TableHeaderCell>
            </asp:TableHeaderRow>
            <asp:TableRow>
                <asp:TableCell>BlanchedAlmond</asp:TableCell>
                <asp:TableCell>#FFEBCD</asp:TableCell>
            </asp:TableRow>
            <asp:TableRow>
                <asp:TableCell>BlueViolet</asp:TableCell>
                <asp:TableCell>#8A2BE2</asp:TableCell>
            </asp:TableRow>
            <asp:TableRow>
                <asp:TableCell>BurlyWood</asp:TableCell>
                <asp:TableCell>#DEB887</asp:TableCell>
            </asp:TableRow>
            <asp:TableRow>
                <asp:TableCell>CadetBlue</asp:TableCell>
                <asp:TableCell>#5F9EA0</asp:TableCell>
            </asp:TableRow>
            <asp:TableRow>
                <asp:TableCell>Chartreuse</asp:TableCell>
                <asp:TableCell>#7FFF00</asp:TableCell>
            </asp:TableRow>
            <asp:TableFooterRow BackColor="Orange" HorizontalAlign=Right>
                <asp:TableCell ColumnSpan="2">Total:5</asp:TableCell>
            </asp:TableFooterRow>
        </asp:Table>
    </div>
    </form>
</body>
</html>
Table.aspx.cs
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Table : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            Table1.ForeColor = System.Drawing.Color.Snow;
            Table1.BackColor = System.Drawing.Color.OrangeRed;
            Table1.BorderWidth = 1;
            Table1.BorderColor = System.Drawing.Color.Orange;
            Table1.CellPadding = 0;
            Table1.CellSpacing = 0;
        }
    }
}




Related asp.net example