单击"更新" FooterTemplate中的下拉列表会无法填充在某一行 这是填充时的页面加载事件:
protected void Page_Load(object sender, EventArgs e)
{
DropDownList ddlImages_new = ((DropDownList)gvAdminArticleAdd.FooterRow.FindControl("ddlImages_new"));
ddlImages_new.DataSource = GetPdfs();
ddlImages_new.DataBind();
DropDownList ddl_invNamesNew = ((DropDownList)gvAdminArticleAdd.FooterRow.FindControl("ddl_invNamesNew"));
ddl_invNamesNew.DataSource = GetInvestigatorNames();
ddl_invNamesNew.DataBind();
}
如果我在某行上单击更新linkButton,则下拉列表中的数据将消失 即使在尝试在取消事件上调用页面加载时它也无法正常工作。
protected void gvAdminArticleAdd_CancelEditEventHandler(object sender, GridViewCancelEditEventArgs e)
{
Page_Load(sender, e);
}
答案 0 :(得分:1)
仅在页面未回发时绑定您的控件:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DropDownList ddlImages_new = ((DropDownList)gvAdminArticleAdd.FooterRow.FindControl("ddlImages_new"));
ddlImages_new.DataSource = GetPdfs();
ddlImages_new.DataBind();
DropDownList ddl_invNamesNew = ((DropDownList)gvAdminArticleAdd.FooterRow.FindControl("ddl_invNamesNew"));
ddl_invNamesNew.DataSource = GetInvestigatorNames();
ddl_invNamesNew.DataBind();
}
}