datasets, dropdownlists, cursors, defaultviews

  • Thread starter Thread starter et
  • Start date Start date
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?
 
ddl.SelectedIndex = ddl.Items.IndexOf(ddl.Items.FindByValue("12345"))

or FindByText depending on which it is.

Karl
 
Thanks for such a quick response!

Do you know if there is a way to to do it using the dataset's defaultview?
 
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
 
Back
Top