Phenomenon:
In the ascx user control, there is a DropDownList that is first entered on this page to bind and display the data normally. Switch a few pages, or point a few other links, and then look at this DropDownList, is empty.
Solve:
Only need to put the DropDownList binding to! In Page.isnotpostback, such as:
if (! Page.IsPostBack)
{
DropDownList ddlproject = Formview1.findcontrol ("Ddlproject") as DropDownList;
DdlProject.Items.Clear ();
foreach (Project information item in coll)
{
DDLPROJECT.ITEMS.ADD (new ListItem (item). ProjectName, item. Projectid.tostring ()));
}
if (DdlProject.Items.Count > 0)
{
for (int i = 0; i < DdlProject.Items.Count; i++)
{
if (ddlproject.items[i). Value = = this. ProjectID)
{
Ddlproject.selectedindex = i;
Break
}
}
}
}
http://four-corner.appspot.com/
====2010-3-2 Update:
I'm sorry. To find the real problem.
DropDownList data binding should be processed in the DataBound event that contains this DropDownList FormView.