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
Thank You… really helpful..
Comment by Nitish — July 24, 2009 @ 6:38 pm
Thank you very much… It was very helpful…
Comment by Mushtaq — July 16, 2010 @ 11:46 am
@Nitish , @Mushtaq : Thank you for your comment hope my post helps you … Good Luck
Comment by yasserzaid — July 16, 2010 @ 5:26 pm
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
Comment by e — August 16, 2010 @ 7:38 am
Thanks for your information GoodLuck
Comment by yasserzaid — August 21, 2010 @ 10:00 pm
Visible=”
can be reduced to
Visible=”
Comment by erratic — January 18, 2011 @ 2:28 pm
ahem, next try:
Visible= '<%# bool.Parse((dlContacts.Items.Count==0).ToString()) %>'
can be reduced to
Visible= ' < %# dlContacts.Items.Count==0 % > '
Comment by erratic — January 18, 2011 @ 2:33 pm
@erratic :- thank you for your information as you know you can find many ways to do something hope my post helps you… GoodLuck
Comment by yasserzaid — January 19, 2011 @ 6:08 am
Thank you … helps a lot
Comment by mohamed — March 1, 2011 @ 8:10 am
thank u
Comment by mohamed — March 1, 2011 @ 8:11 am
@Mohamed :- You are welcome hope my post helps you
Comment by yasserzaid — March 1, 2011 @ 7:46 pm
Thanks Bro!
Varun Maggo
Comment by Varun Maggo — September 2, 2011 @ 11:10 am
@Varun Maggo :- you are welcome Good Luck
Comment by yasserzaid — September 2, 2011 @ 8:41 pm
Good article. Thank you very much
Comment by Mohan Sharma — September 21, 2011 @ 8:47 am
@Mohan Sharma :- You are welcome hope my post helps you
Comment by yasserzaid — September 24, 2011 @ 2:56 pm
[...] Handling Empty Data in DataList control Oct 14th, 2011 Leave a comment | Trackback ReadabilityHandling Empty Data in DataList controlHandling Empty Data in DataList control [...]
Pingback by Jagdeep Kaur » Handling Empty Data in DataList control — October 14, 2011 @ 4:37 pm
Thanks alot.It’s working correctly.
Comment by Shafeeque — November 15, 2011 @ 12:01 pm
@Shafeeque :- You are welcome … Good Luck
Comment by yasserzaid — December 3, 2011 @ 7:06 pm
thnks dude
Comment by kaps — December 8, 2011 @ 9:27 am
thnx
Comment by kaps — December 8, 2011 @ 9:42 am
@kaps :- You are welcome hope my post helps you
Comment by yasserzaid — December 19, 2011 @ 7:16 pm
Thanks . Its very helpful
Comment by shamna Sankar — February 14, 2012 @ 4:41 am
@shamna :- You are welcome
Comment by yasserzaid — February 14, 2012 @ 2:19 pm
Thank you!!
Comment by Yogi — April 19, 2012 @ 11:39 am