Newbiew use of DropDownList.

  • Thread starter Thread starter craigkenisston
  • Start date Start date
C

craigkenisston

Hi,

I think this is the first time I put a dropdownlist in a web form, it
correctly displays the values from the database and when I save the
form I'm able to save the corresponding value to the database. But when
I use the form to display data, the listbox does not automatically
display the value saved in the database of course, so how am I supposed
to make point to the saved value ?
 
Hi,

You can do it one of two ways.

(after ddl is populated)
DropDownList.SelectedIndex =
DropDownList.Items.IndexOf(DropDownList.Items.FindByText(MyDataReader("FieldName")))

or

(if before ddl is populated)
DropDownList.DataTextField=MyDataReader("FieldName")

I hope this helps.

Mike Douglas
 
Back
Top