DropDownList Item Selected doesn't work?

R

Rudy Ko

Hi,

I seem unable to set the selected item in a DropDownList by using the
following code, it always return the toppest (index 0) item, no matter what
i selected.

list.DataSource = GetProductDataSource();
list.DataBind();
item = list.Items.FindByValue("UMTS");
if(item != null)
item.Selected = true;
I steped into the code, and I'm sure that item has been set to true, but the
page still return the toppest item. Anyone can help??
 
R

Roger Helliwell

Hi,

I seem unable to set the selected item in a DropDownList by using the
following code, it always return the toppest (index 0) item, no matter what
i selected.

list.DataSource = GetProductDataSource();
list.DataBind();
item = list.Items.FindByValue("UMTS");
if(item != null)
item.Selected = true;
I steped into the code, and I'm sure that item has been set to true, but the
page still return the toppest item. Anyone can help??
Try,

list.SelectedValue = "UMTS";

Roger
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top