Home > ASP.Net > Handling Empty Data in DataList control

Handling Empty Data in DataList control

Hi

try this Example to Handle Empty Data in Datalist control

<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>

Hope this helps

Good Luck

About these ads
Categories: ASP.Net Tags:
  1. Nitish
    July 24, 2009 at 6:38 pm

    Thank You… really helpful..

  2. July 16, 2010 at 11:46 am

    Thank you very much… It was very helpful…

  3. yasserzaid
    July 16, 2010 at 5:26 pm

    @Nitish , @Mushtaq : Thank you for your comment hope my post helps you … Good Luck

  4. e
    August 16, 2010 at 7:38 am

    There is no built-in empty template for DataList control, but you can use a label to show the message by using your dataSource selected event:

    OnSelected=”SqlDataSource1_Selected”

    Protected Sub SqlDataSource1_Selected(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceStatusEventArgs) Handles SqlDataSource1.Selected

    If e.AffectedRows = 0 Then
    myLabel.Text = “No record found!”
    Else
    myLabel.Text = “”
    End If
    End Sub

  5. yasserzaid
    August 21, 2010 at 10:00 pm

    Thanks for your information GoodLuck

  6. erratic
    January 18, 2011 at 2:28 pm

    Visible=”
    can be reduced to
    Visible=”

  7. erratic
    January 18, 2011 at 2:33 pm

    ahem, next try:

    Visible= '<%# bool.Parse((dlContacts.Items.Count==0).ToString()) %>'
    can be reduced to
    Visible= ' < %# dlContacts.Items.Count==0 % > '

  8. yasserzaid
    January 19, 2011 at 6:08 am

    @erratic :- thank you for your information as you know you can find many ways to do something hope my post helps you… GoodLuck

  9. mohamed
    March 1, 2011 at 8:10 am

    Thank you … helps a lot

  10. March 1, 2011 at 8:11 am

    thank u

  11. yasserzaid
    March 1, 2011 at 7:46 pm

    @Mohamed :- You are welcome hope my post helps you :)

  12. September 2, 2011 at 11:10 am

    Thanks Bro!

    Varun Maggo

  13. yasserzaid
    September 2, 2011 at 8:41 pm

    @Varun Maggo :- you are welcome Good Luck

  14. September 21, 2011 at 8:47 am

    Good article. Thank you very much

  15. yasserzaid
    September 24, 2011 at 2:56 pm

    @Mohan Sharma :- You are welcome hope my post helps you

  16. Shafeeque
    November 15, 2011 at 12:01 pm

    Thanks alot.It’s working correctly.

  17. yasserzaid
    December 3, 2011 at 7:06 pm

    @Shafeeque :- You are welcome … Good Luck

  18. kaps
    December 8, 2011 at 9:27 am

    thnks dude

  19. kaps
    December 8, 2011 at 9:42 am

    thnx

  20. yasserzaid
    December 19, 2011 at 7:16 pm

    @kaps :- You are welcome hope my post helps you

  21. shamna Sankar
    February 14, 2012 at 4:41 am

    Thanks . Its very helpful

  22. yasserzaid
    February 14, 2012 at 2:19 pm

    @shamna :- You are welcome ;)

  23. Yogi
    April 19, 2012 at 11:39 am

    Thank you!!

  24. August 24, 2012 at 11:21 pm

    The code is for C#
    For VB use this:

    Visible=”

  25. Ajay
    November 4, 2012 at 9:56 am

    thanks…Ajay

  26. yasserzaid
    November 5, 2012 at 8:26 am

    @Ajay : you are welcome :)

  27. kpari
    April 5, 2013 at 12:08 am

    Thank you! Works like a charm!

    • yasserzaid
      April 9, 2013 at 9:25 am

      @kpari : you are welcome .. hope my post helps you

  28. April 15, 2013 at 1:23 pm

    Hi, I think your blog might be having internet browser compatibility
    issues. When I take a look at your site in Safari, it looks fine
    however, when opening in I.E., it’s got some overlapping issues. I simply wanted to give you a quick heads up! Apart from that, fantastic site!

  29. April 18, 2013 at 8:15 pm

    Fascinating blog! Is your theme custom made or did you download it from somewhere?

    A design like yours with a few simple tweeks would really make
    my blog jump out. Please let me know where you got your theme.
    Cheers

  1. October 14, 2011 at 4:37 pm

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 )

Google+ photo

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

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 36 other followers

%d bloggers like this: