varunmaggo's say

Getting better never stops!

How to handle Empty Data in ASP.NET DataList and GridView

leave a comment »

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

Written by Varun Maggo

September 2, 2011 at 11:09 am

Posted in Uncategorized

Tagged with

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.