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; }
/** @property */
public GridLines get_GridLines ()

/** @property */
public void set_GridLines (GridLines value)

public function get GridLines () : GridLines

public function set GridLines (value : GridLines)

Property Value

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

Description

None

No cell borders are displayed.

Horizontal

Only the horizontal cell borders are displayed.

Vertical

Only the vertical cell borders are displayed.

Both

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.

NoteNote

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#" AutoEventWireup="True" %>

<html>
<head>

   <script runat="server">

      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 r = new TableRow();
                
            for(int i=0; i <= numcells - 1; i++)
            {
            
               TableCell c = new TableCell();
               c.Controls.Add(new LiteralControl("row " + j.ToString() + 
                              ", cell " + i.ToString()));
               r.Cells.Add(c);

            }
                
            Table1.Rows.Add(r);

         }

      }

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

    </script>

</head>

<body>

   <h3>Table GridLines Example</h3>

   <form runat="server">

      <asp:Table id="Table1" 
           BorderColor="black" 
           BorderWidth="1" 
           GridLines="Both" 
           runat="server"/>

      <p>

      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"
           OnClick="Button_Click" 
           runat=server/>
        
   </form>

</body>
</html>
    

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

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

.NET Framework

Supported in: 2.0, 1.1, 1.0
Show: