I'm creating controls dynamically in the ItemCreated event of my grid. I'm adding these controls to my edit form (WebUserControl) for insert/update. All my textbox type controls work fine but my dropdown control seems to lose its items after postback. How can I get it to keep it values/viewstate after postback? Thanks.
protected void rgData_ItemCreated(object sender, GridItemEventArgs e)
{
if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
{
UserControl edit = e.Item.FindControl(GridEditFormItem.EditFormUserControlID) as UserControl;
..........................................
switch (type)
{
case CustomFieldTypeController.CustumFieldTypeEnum.Boolean:
c = new DropDownList();
((DropDownList)c).Items.Add(new ListItem("--Select--", ""));
((DropDownList)c).Items.Add(new ListItem("true", "true"));
((DropDownList)c).Items.Add(new ListItem("false", "false"));
break;
protected void rgData_ItemCreated(object sender, GridItemEventArgs e)
{
if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
{
UserControl edit = e.Item.FindControl(GridEditFormItem.EditFormUserControlID) as UserControl;
..........................................
switch (type)
{
case CustomFieldTypeController.CustumFieldTypeEnum.Boolean:
c = new DropDownList();
((DropDownList)c).Items.Add(new ListItem("--Select--", ""));
((DropDownList)c).Items.Add(new ListItem("true", "true"));
((DropDownList)c).Items.Add(new ListItem("false", "false"));
break;