Thursday, March 22, 2012

Setting the Drop-down listbox Default value

ok, this seems like it should be an easy enough task...

I want to be able to set which item is selected in a Drop-down listbox based upon a database query... This is on an .aspx.vb page.

DDL_Choice1.SelectedItem.Text = "whatever value"

- this doesn't work because it over-writes the first value in the list with the value specified.

DDL_Choice1.Items("whatever value").Selected = True

-this doesn't work either because "whatever value" MUST be the index of the item you want selected, which I don't know because the items in the dropdown list are dymanically created as well.

there has to be a simple way to specify which VALUE is selected (in the VB code-behind-page)...ddl.Items.FindByText("TextToFind").Selected = true;

John

0 comments:

Post a Comment