Is it possible to perform a postback and have the viewstate remember the selected value on the following code?
It seems placeholder1.controls.clear() is deleting it.
protected void Page_Load(object sender, EventArgs e)
{
bind();
}
protected void bind()
{
PlaceHolder1.Controls.Clear();
DropDownList ddl = new DropDownList() { AutoPostBack = true, ID="ddl" };
ddl.SelectedIndexChanged += new EventHandler(ddl_SelectedIndexChanged);
ddl.Items.Add("hi");
ddl.Items.Add("bye");
PlaceHolder1.Controls.Add(ddl);
}
void ddl_SelectedIndexChanged(object sender, EventArgs e)
{
bind();
}