Tuesday, January 12, 2010

EmptyDataTemplate in a GridView

You can use the EmptyDataTemplate in your gridviews to display a message when “no data is found”.  This is an alternative to using code to check the number of rows in the gridview and show/hiding some label to indicate this.  The EmptyDataTemplate goes before the column definitions.

<asp:GridView ID="gvAuthorityExemptions"

AutoGenerateColumns="false" GridLines="None"

runat="server" Width="100%"> 
      
<EmptyDataTemplate>

<asp:Label ID="lblNoData" runat="server">

No Exemptions for License/Authority

</asp:Label>

</EmptyDataTemplate> 
      
<Columns>

No comments:

Post a Comment