ObjectDataSource has no data

D

Dot Net Daddy

Hello,

I have an objectDateSource. But sometime there might not be any data
for my application. So how can I know if the objectDataSource has no
data? I binded a dropdownlist to this objectDataSource and I want to
set the dropdownlist.visible = False, if there is no data.

Thank You,
 
G

Guest

Well! If you bind your dropdownlist to your ODS and its items count property
is zero, then can't you go ahead and set its visibility to false based on
that?
Peter
 
D

Dot Net Daddy

The problem is there for me.

First of all I am new to asp.net as you may have noticed. And secondly
there is not such a method like:

ObjectDataSource.Items.Count

that's why I'm stuck.
 
D

Dot Net Daddy

I had already tried what you said but it hadn't worked either. But now
I got why it didnt work.

Because the dropDownList is databinded, and it doesn't contain any info
on every Page_Load it always returned 0 for list.items.count..
my fault was writing that code in page_load function.

Now I changed it to:

Protected Sub DropDownList1_DataBound(ByVal sender As Object, ByVal
e As System.EventArgs) Handles DropDownList1.DataBound
If DropDownList1.Items.Count.Equals(0) Then
DropDownList1.Visible = False
End If
End Sub

and it works fine..

thank you anyway for your help..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top