DropDownList Item Selected doesn't work?

  • Thread starter Thread starter Rudy Ko
  • Start date Start date
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??
 
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
 
Back
Top