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
Categories: ASP.Net
Empty Data
Thank You… really helpful..
Thank you very much… It was very helpful…
@Nitish , @Mushtaq : Thank you for your comment hope my post helps you … Good Luck
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
Thanks for your information GoodLuck
Visible=”
can be reduced to
Visible=”
ahem, next try:
Visible= '<%# bool.Parse((dlContacts.Items.Count==0).ToString()) %>'
can be reduced to
Visible= ' < %# dlContacts.Items.Count==0 % > '
@erratic :- thank you for your information as you know you can find many ways to do something hope my post helps you… GoodLuck
Thank you … helps a lot
thank u
@Mohamed :- You are welcome hope my post helps you 🙂
Thanks Bro!
Varun Maggo
@Varun Maggo :- you are welcome Good Luck
Good article. Thank you very much
@Mohan Sharma :- You are welcome hope my post helps you
Thanks alot.It’s working correctly.
@Shafeeque :- You are welcome … Good Luck
thnks dude
thnx
@kaps :- You are welcome hope my post helps you
Thanks . Its very helpful
@shamna :- You are welcome 😉
Thank you!!
The code is for C#
For VB use this:
Visible=”
thanks…Ajay
@Ajay : you are welcome 🙂
Thank you! Works like a charm!
@kpari : you are welcome .. hope my post helps you
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!
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
It’s an awesome article in support of all the online people; they will take benefit from it I am sure.
Thank you