2.2.Â Generating a Quick-and-Dirty Tabular Display
You want to display data from a database in a table, and youâre not overly concerned about performance or your ability to control the arrangement of the data items within the display.
GridView control and bind the data to it.
In the .aspx file, add the
GridView control responsible for displaying the data.
In the code-behind class for the page, use the .NET language of your choice to:
ConnectionString, DataSourceMode, ProviderName, and
SelectCommandproperties of the
Assign the data source to the
GridViewcontrol and bind it.
FigureÂ 2-1.Â Quick-and-dirty GridView output
Implementing a simple
GridView requires little coding. You must first add a
GridView control to the .aspx file for your application and set a few of its attributes, as shown in Example 2-1. The
GridView control has many attributes you can use to control the creation of a
GridView object, but only three are required for this example: the
id, runat, and
AutoGenerateColumns attributes. The
runat attributes are required by all server controls. When the
AutoGenerateColumns attribute is set to
True, it causes the ...