GridView Display Properties
Other usage samples:
Simple GridView |
AutoGenerated Columns |
Template Fields |
BindAttribute |
Row Selection |
Paging |
Sorting |
Inline Editing |
Selection |
Display Properties |
This sample demonstrates visual and structural properties:
Caption, GridLines, ShowHeader,
ShowFooter, EmptyDataTemplate, and
UseAccessibleHeader.
Caption & GridLines
The Caption property adds a caption above the table.
GridLines controls which cell borders are rendered.
| ID | Name | Department |
|---|---|---|
| 1 | Alice Johnson | Engineering |
| 2 | Bob Smith | Marketing |
| 3 | Carol White | Engineering |
| 4 | Dave Brown | Sales |
ShowHeader / ShowFooter
Toggle ShowHeader and ShowFooter to control row visibility.
| ID | Name | Department |
|---|---|---|
| 1 | Alice Johnson | Engineering |
| 2 | Bob Smith | Marketing |
| 3 | Carol White | Engineering |
| 4 | Dave Brown | Sales |
EmptyDataTemplate
When the data source is empty, the EmptyDataTemplate is displayed.
No employees found.
Try adjusting your search criteria. |
Code Example
<GridView ItemType="Employee"
Items="@_employees"
Caption="Employee Directory"
GridLines="GridLines.Both"
UseAccessibleHeader="true"
ShowHeader="true"
ShowFooter="false">
<EmptyDataTemplate>
<p>No data available.</p>
</EmptyDataTemplate>
<Columns>
<BoundField DataField="Name" HeaderText="Name" />
</Columns>
</GridView>