Getting value from dynamic controls postback problem

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

I create a dynamic control and added it to a panel.

I get the selected value of the control via a btn_click()
but my problem is everytime the page is postback the selected values go back
to the first element in the dropdownlist.

but if i call the control creation with if !=postback then the controls
disappear. and selected values = null.

Any help on this would be great

Thanks all.
 
Very strange thing....
if i give the dropdownlist item's properties:
..Text and .Value
the same value eg. "abc" The btn_click() displays the correct values over
postback, but if one (either .Text or .Value is different it fails.)
anyone know why this should happen??


ListItem tmpResidentListItem;
tmpResidentListItem = new ListItem();
tmpResidentListItem.Text =
getOptionItemName(Convert.ToInt32(myRow2["itemID"].ToString()));
tmpResidentListItem.Value =
getOptionItemName(Convert.ToInt32(myRow2["itemID"].ToString()));
MyDdl.ID = "ddl" + myRow2["categoryID"].ToString();
MyDdl.EnableViewState = true;
MyDdl.Items.Add(tmpResidentListItem);

pnlOptionDdl.Controls.Add( MyDdl );


Thanks
Mike
 
Back
Top