I have used gridviews in my asp.net 2.0 applications. One of the requirement is to show the header row even when there are no data rows in dataset. I couldn't find an easy way of doing this. After little bit of R&D, i did that with EmptyDataTemplate of GridView. This works well but is there any easy way of doing this?
EDIT on 15-Nov-2007:
Following is the sample code of what i did in my application. In this i wanted to show two fields Year and extract date. BTW, this sample is not specific to VB or C# as this code belongs to aspx page.
code:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1"
Width="75%" BorderColor="Black" BorderStyle="Solid" OnRowDataBound="GridView1_RowDataBound" OnDataBound="GridView1_DataBound" AllowPaging="True">
<Columns>
<asp:BoundField DataField="YEAR" HeaderText="Year" >
<HeaderStyle Font-Underline="True" />
</asp:BoundField>
<asp:BoundField DataField="EXTRACT_DATE" HeaderText="Last Extract" >
<HeaderStyle Font-Underline="True" />
</asp:BoundField>
</Columns>
<EmptyDataTemplate>
<table width="100%">
<tr style="font-weight:bold; text-decoration:underline" align="center">
<td>
Year
</td>
<td>
Last Extract
</td>
</tr>
</table>
<br />
No Records Found for Review
</EmptyDataTemplate>
</asp:GridView>