regor

regor

  • NA
  • 61
  • 0

Change the SelectedItem value after selecing from a DropDownList and clicked button

Dec 1 2009 6:59 AM
Hi, I have just started to use a ListItem[] in order to avoid using the collection property in the DropDownList so I have a list of items with their respective names and the values they should have behind them as follows: private void InitializeDelivPointDropDown() { items[0] = new ListItem("Select", "-1"); items[1] = new ListItem("WareTest 1", "IPaddress"); items[2] = new ListItem("WareTest 2", "IPaddress"); items[3] = new ListItem("28A", "IPaddress"); items[4] = new ListItem( "26T","IPaddress"); items[5] = new ListItem("B9 2","IPaddress"); items[6] = new ListItem("B9 8","IPaddress"); items[7] = new ListItem("All Delivery Points", "0"); WorkcellDropDownList.Items.Clear(); WorkcellDropDownList.Items.AddRange(items); } now, when this code runs it initiates the value of the WorkcellDropDownList to be the first one. So when running my scan button after I have selected a new index in the dropdownlist it still keeps the last values. also I am running this code under the Page_Load but it seems that as soon as I click the button it runs the Page_Load event which is not what I would thought it would do, any way to change this? Thanks!

Answers (1)