How to handle Empty Data in ASP.NET DataList and GridView
Go to your aspx web form and try this
<asp:DataList ID="dlContacts" runat="server"> <ItemTemplate> <!-- Add your Item Template Here --> </ItemTemplate> <FooterTemplate> <asp:Label ID="lblEmpty" Text="no result" runat="server" Visible='<%#bool.Parse((dlContacts.Items.Count==0).ToString())%>'> </asp:Label> </FooterTemplate> </asp:DataList> For GridView: <EmptyDataTemplate> <table border="0px" cellpadding="5" cellspacing="5"> <tr><td> Error Message here! </td> </tr> </table> </EmptyDataTemplate> <EmptyDataRowStyle CssClass="empty" ForeColor="Red" />
Advertisement