I have a user control and a dynamically created dropdownlist on it. When I select an item in the ddl data is supposed to go into a textbox. The problem is that the SelectedIndexChanged event is only fired the second time I select some item in the ddl.
I think the problem has something to do with the viewstate - it's like the event isn't registered in the viewstate the first time I load the user control??
Here is my code which is in the Page_Load function in the user control:
DropDownList cboBUNK = new DropDownList();
cboBUNK.ID = "m_cboBUNK";
cboBUNK.CssClass = "controlText";
cboBUNK.AutoPostBack = true;
cboBUNK.SelectedIndexChanged += new EventHandler( onCboBUNKSelectedIndexChanged );
cboBUNK.DataSource = colBunkanr;
cboBUNK.DataTextField = "BUNK";
cboBUNK.DataValueField = "BUNK";
cboBUNK.SelectedIndex = 0;
m_plhBUNK.Controls.Add( cboBUNK );