Forum Moderators: open

Message Too Old, No Replies

Checking for an empty datalist

How?

         

chris_f

9:09 am on Jan 30, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi All,

I'm really kicking myself for this one. I've gone through all my books and searched the web but I just can't find the solution to this one. I am writting ASP.net (VB) and need to check if my datalist (populated from an Access db via a DataSet) is empty. If it is, I want to display a message where the content should be. Any pointers will be helpful.

Many Thanks
Chris

sComm2 = "SELECT CategoryName, "
sComm2 += "CategoryDescription, "
sComm2 += "ParentCategory "
sComm2 += "FROM Categories "
sComm2 += "WHERE CategoryID = " & Request.QueryString("Category")

oConn2 = New OleDbConnection(sConn)
oComm2 = New OleDbDataAdapter(sComm2, oConn2)

oComm2.Fill(oDataSet2, "CategoryInfo")

oGrid2.DataSource=oDataSet2.Tables("CategoryInfo").DefaultView
oGrid2.DataBind()

...
...
...

<asp:DataList id="oGrid2" runat="server">
<ItemTemplate>
<strong><%# DataBinder.Eval(Container.DataItem, "CategoryName") %></strong> - (<a href="directory.aspx?category=<%# DataBinder.Eval(Container.DataItem, "ParentCategory") %>">category up</a> )<br />
<%# DataBinder.Eval(Container.DataItem, "CategoryDescription") %>
</ItemTemplate>
</asp:DataList>

korkus2000

3:44 pm on Feb 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What about just doing a count query on the database and using your logic there?

RossWal

6:28 pm on Feb 2, 2004 (gmt 0)

10+ Year Member



Or maybe:

oDataSet2.Tables("CategoryInfo").Rows.Count > 0

or

oDataSet2.Tables.Count > 0

..... just guessing here......

Ross

chris_f

12:01 pm on Feb 3, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks Guys,

I'll have a play when I'm next working on this project again.

atob.c