.NET Framework Class Library
GridView.ShowHeader Property
Gets or sets a value indicating whether the header row is displayed in a GridView control.
Assembly: System.Web (in System.Web.dll)
Syntax
Visual Basic
Public Overridable Property ShowHeader As Boolean
C#
public virtual bool ShowHeader { get; set; }
Visual C++
public: virtual property bool ShowHeader { bool get (); void set (bool value); }
F#
abstract ShowHeader : bool with get, set override ShowHeader : bool with get, set
ASP.NET
<asp:GridView ShowHeader="True|False" />
Property Value
Type: System.Booleantrue to display the header row; otherwise, false. The default is true.
Remarks
Use the ShowHeader property to specify whether a GridView control displays the header row. To control the appearance of the header row, use the HeaderStyle property.
Examples
The following example demonstrates how to use the ShowHeader property to display the header row in a GridView control.
Visual Basic
<%@ Page language="VB" %> <!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>GridView ShowHeader and ShowFooter Example</title> </head> <body> <form id="form1" runat="server"> <h3>GridView ShowHeader and ShowFooter Example</h3> <asp:gridview id="CustomersGridView" datasourceid="CustomersSource" autogeneratecolumns="true" emptydatatext="No data available." showheader="true" showfooter="true" runat="server"> <headerstyle backcolor="LightCyan" forecolor="MediumBlue"/> <footerstyle backcolor="LightCyan" forecolor="MediumBlue"/> </asp:gridview> <!-- This example uses Microsoft SQL Server and connects --> <!-- to the Northwind sample database. Use an ASP.NET --> <!-- expression to retrieve the connection string value --> <!-- from the Web.config file. --> <asp:sqldatasource id="CustomersSource" selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]" connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" runat="server"/> </form> </body> </html>
C#
<%@ Page language="C#" %> <!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>GridView ShowHeader and ShowFooter Example</title> </head> <body> <form id="form1" runat="server"> <h3>GridView ShowHeader and ShowFooter Example</h3> <asp:gridview id="CustomersGridView" datasourceid="CustomersSource" autogeneratecolumns="true" emptydatatext="No data available." showheader="true" showfooter="true" runat="server"> <headerstyle backcolor="LightCyan" forecolor="MediumBlue"/> <footerstyle backcolor="LightCyan" forecolor="MediumBlue"/> </asp:gridview> <!-- This example uses Microsoft SQL Server and connects --> <!-- to the Northwind sample database. Use an ASP.NET --> <!-- expression to retrieve the connection string value --> <!-- from the Web.config file. --> <asp:sqldatasource id="CustomersSource" selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]" connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" runat="server"/> </form> </body> </html>
Version Information
.NET Framework
Supported in: 4, 3.5, 3.0, 2.0Platforms
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.
See Also