I'm binding to a dropdown. It works on the initial load. On subsequent loads (postbacks) it doesn't refresh the items in the dropdown.
using (DataView dv = dtProductGroup.DefaultView)
{
dv.ApplyDefaultSort = false;
dv.Sort = "KVIGroupName ASC";
ddlGroup.ClearSelection();
ddlGroup.Items.Clear();
string strAll = Localization.GetResourceValue("_strddlStatusLBAll");
ddlGroup.DataValueField = "KVIGroupId";
ddlGroup.DataTextField = "KVIGroupName";
ddlGroup.DataSource = dv;
ddlGroup.DataBind();
ListItem item = new ListItem(strAll, "0");
ddlGroup.Items.Insert(0, item);
}
I've confirmed that on the postbacks the data is being bound to the dropdown and items are successfully added. But when the page renders the dropdown doesn't have any of the new values.
I see two possibilities: The control isn't rendering the new values or the values are being cleared. I'm at a loss of where to look for possible problems.
Edit
I discovered the problem. The dropdownlist was embedded in an Conditional UpdatePanel. Simply calling "UpdatePanel.Update();" solved the problem.