asp.net.ph

Skip Navigation Links

GridView Control Syntax

ASP.NET Syntax   ASP.NET Syntax for Web Controls


Displays the values of a data source in a table where each column represents a field and each row represents a record. The GridView control allows you to sort, page, select, and update these items.

Declarative Syntax

For information on the individual members of this class, see GridView in the class library.

Remarks

The GridView control renders the contents of a data source into a grid-like table. Each column represents a field and each row represents a record.

For more information on using the GridView control, see GridView Web Server Control.

Syntax Example

The following example demonstrates how to use the GridView control to display the values from the Customers table of the NorthWind sample database in Microsoft SQL Server. The values are retrieved using a SqlDataSource control.

<asp:gridview id="CustomersGridView" runat="server"
   datasourceid="customers"
   width=80% cellpadding=5
   font-size = "9pt">

   <headerstyle backcolor = "steelblue"
      forecolor = "beige" />

   <rowstyle verticalalign = "top" />

</asp:gridview>

<asp:sqldatasource id="customers" runat="server"
   selectcommand = "SELECT CustomerID, CompanyName, Address, City, PostalCode, Country" +
      " FROM Customers"
   connectionstring = "<%$ ConnectionStrings:aspnet %>"
   datasourcemode = "DataReader" />

 Show me 

See Also

GridView Class   GridView Web Server Control



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note