datasets, dropdownlists, cursors, defaultviews

E

et

I need to get a bound dropdown list to display a particular list item, not
the first one. When I use ddl.selecteditem.text = "12345", or
ddl.selecteditem.value="ID12345", it changes the value of the first item,
not point to the item in the list that matches that item.

I believe I can use a defaultview with the dataset to point to, for
instance, the 5th item in the list; if no, how would I do that?

If I choose to use the dropdown list to point to a particular item, how
would I do that?
 
K

Karl Seguin

ddl.SelectedIndex = ddl.Items.IndexOf(ddl.Items.FindByValue("12345"))

or FindByText depending on which it is.

Karl
 
E

et

Thanks for such a quick response!

Do you know if there is a way to to do it using the dataset's defaultview?
 
K

Karl Seguin

I'm afraid one of us is at a loss, not sure I understand what you are
asking..but...

DefaultView returns a DataView which you could use for binding to the ddl,
but not sure why/how you would use it to set the selected item:

ddl.DataItem = DataSet
ddl.DataBound
ddl.SelectedIndex = ddl.....

or you could use DataSet.Tables[0].DefaultView instead of DataSet but that's
the same thing..

Karl
 

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

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top