因此,我在UpdatePanel中有一个ListView(assignmentsListView),由同一UpdatePanel中的DropDownList过滤。DropDownList中有一个人员列表并使用autopostback,ListView显示这些人员分配给的任务。
我试图使用类似的代码:
protected void assignmentsListView_DataBound(object sender, EventArgs e)
{
string resFirstName = Utilities.getResourceFirstName(resDdl.SelectedValue);
if (assignmentsListView.Items.Count <= 0)
{
}
else
{
ImageButton exportButton = (ImageButton)assignmentsListView.FindControl("ImageButton3");
ScriptManager scriptManager = ScriptManager.GetCurrent(this.Page);
ScriptManager.RegisterPostBackControl(exportButton);
}
}
当我第一次加载页面时,DropDownList显示列表中的第一个人,而ListView正确地显示该人的任务。
如果我选择一个我知道没有任务的人,那么在RegisterPostBackControl()方法中会得到一个错误,说传入的控件不能为空。
调试时,在RegisterPostBackControl方法中,它显示ListView项集合中有>0个元素(元素的数量与在当前人员之前选定的人员匹配)。
发生什么事?有什么建议吗?