ListBox.SelectedValue weirdness

S

Sosh

Hi,

Maybe someone could shed some light on the following situation. I
have a ListBox wich I have bound with some names and ids. I then get
do another query to bind some info to page,and also pre-select the
appropiate item on the ListBox.

I am using an dataset for the second query the second query.

I start by doing something like this:

theListBox.SelectedValue = ds.Tables[0].Rows[0]["ID"] as String;

However, nothing gets seleted, even though the values match. In fact
the MS documentation says it throws an exception if you try to set it
to something that does not exists. So I test that:

theListBox.SelectedValue = "123456";

Sure enough I get the exception. Then I try:

theListBox.SelectedValue = ds.Tables[0].Rows[0]["ID"].ToString();

And it works. Can anyone tell my why using the first method it
neither works properly nor throws an exception?

Thanks.
 

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
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top