したがって、UpdatePanel に ListView (assignmentsListView) があり、同じ UpdatePanel の DropDownList によってフィルター処理されます。DropDownList には人のリストがあり、自動ポストバックを使用します。ListView は、それらの人が割り当てられているタスクを示します。
私はこれに似たコードを使用しようとしています:
protected void assignmentsListView_DataBound(object sender, EventArgs e)
{
string resFirstName = Utilities.getResourceFirstName(resDdl.SelectedValue);
if (assignmentsListView.Items.Count <= 0)
{
//Show error message
}
else
{
//Try to find the ImageButton in the ListView's header template.
ImageButton exportButton = (ImageButton)assignmentsListView.FindControl("ImageButton3");
//Register this button as a PostBack event in the Master Page
ScriptManager scriptManager = ScriptManager.GetCurrent(this.Page);
ScriptManager.RegisterPostBackControl(exportButton);
}
}
ページを最初に読み込むと、DropDownList はリストの最初の人を表示し、ListView はその人のタスクを正しく表示します。
次に、タスクがゼロであることがわかっている人物を選択すると、RegisterPostBackControl() メソッドで、渡されたコントロールを null にすることはできないというエラーが表示されます。
デバッグ中、RegisterPostBackControl メソッドで、ListView Items コレクションに 0 個以上の要素が含まれていることが示されます (要素の数は、現在の人物の前に選択された人物と一致します)。
どうしたの?助言がありますか?