I've got a gridview and I want it to display the header row even if there isn't any data in the collection that it's binding to.
Any ideas on how to do this neatly?
I've got a gridview and I want it to display the header row even if there isn't any data in the collection that it's binding to.
Any ideas on how to do this neatly?
Use the <EmptyDataTemplate>
of the GridView
control to define a table to be displayed if the data source contains no data. For example
<EmptyDataTemplate>
<table class="Standard" cellspacing="0" cellpadding="0">
<tr>
<th style="width: 25%;">
Header 1</th>
<th style="width: 25%;">
Header 2</th>
<th style="width: 25%;">
Header 3</th>
<th style="width: 25%;">
Header 4`</th>
</tr>
<tr>
<td style="text-align: center; font-size: 1em; font-style: italic; padding: 1em 1em 1em 1em;"
colspan="4">
--- No results found ---
</td>
</tr>
</table>
</EmptyDataTemplate>
Dears i was writing in my blog about this issue but for c# , you can review the post and check if it will be helpful or not ,
http://blog.waleedmohamed.net/2009/04/show-grid-view-header-and-footer-when.html
i was using a generic way with an helper to retrieve an empty list to fill the gird please check and if u have any quest don't hesitate to contact me or ask it on stack site