Hi, I'm using a GridView to display some ifnromation in ASP.NET. I need it to simply display 0 in the gridview fields (there's only ever one row returned) if the dataset is empty, plus of course display the headers. How do I do this?
+1
A:
Hey,
Yes bind a dummy dataset with one row, with all zeros as fields, to the grid with zeros as the field labels. That would be the best way.
Brian
2010-10-12 12:38:59
A:
Bind your grid and add the EmptyDataTemplate like so:
<asp:GridView ID="gridview1" runat="server" ShowFooter="true">
<Columns>
<asp:BoundField DataField="id" HeaderText="ID field" />
</Columns>
<EmptyDataTemplate>put whatever you want in here</EmptyDataTemplate>
</asp:GridView>
adrianos
2010-10-12 12:43:45