The Data Controls The Rich Data Controls Include The Following
The Data Controls The Rich Data Controls Include The Following
When it comes to data binding, not all ASP.NET controls are created equal.
The rich data controls include the following:
GridView: The GridView is an all-purpose grid control for showing large tables of
information.
DetailsView: The DetailsView is ideal for showing a single record at a time, in a
table that has one row per field.
FormView: Like the DetailsView, the FormView shows a single record at a time
and supports editing.
ListView: The ListView plays the same role as the GridView—it allows you to
show multiple records.
The GridView
The GridView is an extremely flexible grid control that displays a multicolumn
table.
Each record in your data source becomes a separate row in the grid.
The GridView is the most powerful of the three rich data controls.
• This functionality includes features for automatic paging, sorting,
selecting, and editing.
Automatically Generating Columns
• The GridView automatically generates a column for every field, as long as
the AutoGenerateColumns property is true.
All you need to create a basic grid with one column for each field:
• <asp:GridView ID="GridView1" runat="server" />
Defining Columns
By default, the GridView.AutoGenerateColumns property is true, and the
GridView creates a column for each field in the bound DataTable.
The most basic column type is BoundField, which binds to one field in the
data object.
Configuring Columns
When you explicitly declare a bound field, you have the opportunity to set
other properties
Property Description
Identifies the field (by name) that you want to display in this
DataField column
Formats the field
DataFormatString
If true, the DataFormat string is used to format the value even
ApplyFormatInEditMode when
the value appears in a text box in edit mode
Sets the text in the header and footer region
FooterText, HeaderText, and
HeaderImageUrl
If true, it prevents the value for this column from being changed
ReadOnly in
edit mode
If true, it prevents the value for this column from being set in
InsertVisible insert
mode
If false, the column won’t be visible in the page
Visible
SortExpression Sorts your results based on one or more columns
PageIndex Gets or sets the zero-based index of the currently displayed page
Provides a PagerSettings object that wraps a variety of formatting options for the
PagerSettings pager controls
Provides a style object you can use to configure fonts, colors, and
PagerStyle text alignment for the paging controls.