This documentation is archived and is not being maintained.

Table.GridLines Property

Gets or sets the grid line style to display in the Table control.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

public virtual GridLines GridLines { get; set; }
<asp:Table GridLines="GridLines" />

Property Value

Type: System.Web.UI.WebControls.GridLines
One of the GridLines enumeration values. The default value is None.

Use the GridLines property to specify which cell borders are displayed in the Table control. The following table lists the different grid line styles.

GridLine value



No cell borders are displayed.


Only the horizontal cell borders are displayed.


Only the vertical cell borders are displayed.


Both the horizontal and vertical cell borders are displayed.

The following example demonstrates how to use the GridLines property to specify the grid line style.


The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see ASP.NET Web Page Code Model.

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 

<script runat="server">

    private void Page_Load(Object sender, EventArgs e)
        // Generate rows and cells.    
        int numrows = 5;
        int numcells = 4;

        for(int j=0; j<=numrows - 1; j++)
            TableRow rw = new TableRow();

            for(int i=0; i <= numcells - 1; i++)
               TableCell cel = new TableCell();
               cel.Controls.Add(new LiteralControl(
                   String.Format("row {0}, cell {1}", j, i)));


    private void Button_Click(Object sender, EventArgs e)
        Table1.GridLines = (GridLines)DropDown1.SelectedIndex;


<html xmlns="" >
<head runat="server">
    <title>Untitled Page</title>
    <form id="form1" runat="server">

    <h3>Table GridLines Example</h3>

    <asp:Table id="Table1" 
        runat="server" />

    <br />GridLines:

    <asp:DropDownList id="DropDown1" runat="server">
        <asp:ListItem Value="0">None</asp:ListItem>
        <asp:ListItem Value="1">Horizontal</asp:ListItem>
        <asp:ListItem Value="2">Vertical</asp:ListItem>
        <asp:ListItem Value="3">Both</asp:ListItem>
    </asp:DropDownList><br />

    <asp:button id="Button1"
        Text="Display Table"
        runat="server" />


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.