本文介绍了如何填写asp.net ListView控件的EditItemTemplate中的dropdownlist的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望在激活编辑时填充ListView EditItemTemplate中的DropDownList。我试过这段代码。但是,EditItem为null,它会抛出NullReferenceException。
I want to fill a DropDownList in my ListView EditItemTemplate when Edit is activated. I tried this code. But, The EditItem is null, and it throws a NullReferenceException.
protected void ListView3_ItemEditing(object sender, ListViewEditEventArgs e)
{
if (e.NewEditIndex >= 0 && ListView3.Items[e.NewEditIndex].ItemType == ListViewItemType.DataItem)
{
object _edSubPro = ListView3.EditItem.FindControl("edListSubProject");
if (_edSubPro != null && _edSubPro is DropDownList)
{
DropDownList _edSubProDP = (DropDownList)_edSubPro;
BindDropDownList(_edSubProDP, "select SubProjectID, (LEFT(SubProjectCode + REPLICATE(' ' , 7), 7) + ' | ' + SubProjectName) AS SubProjectName from SubProject", "SubProject", "SubProjectName", "SubProjectID");
}
}
}
推荐答案
这篇关于如何填写asp.net ListView控件的EditItemTemplate中的dropdownlist的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!