I've recently found out that in order for Dynamic Controls to retain
their values during postback, they must be declared in Page_Init as
follows:
protected void Page_Init(object sender, EventArgs e)
{
DropDownList dd = new DropDownList();
dd.Items.Add(new ListItem("Item 1"));
dd.Items.Add(new ListItem("Item 2"));
dd.AutoPostBack = true;
panel1.Controls.Add(dd);
}
Since the control is set for AutoPostback, it retains it's value once the SelectedIndex is changed.
I now have another problem - I also want to create an ImageButton which
has it's CommandArgument changed to the value selected in the dropdown.
However, this ImageButton is also dynamically created, in Page_Init,
since these are actually a part of a Table automatically generated, and
are on each r ...
Go to the complete details ...