您的位置:首页 > 运维架构

GridView绑定DropDownList的小问题

2007-11-27 16:25 357 查看
在点GridView的编辑按钮时候 对DropDownList的数据进行绑定.

DropDownList所在的列是摸板列,

在RowEditing事件下如下源码

DropDownList ddl = this.GridViewMemberAccount.Rows[e.NewEditIndex].Cells[0].Controls[1] as DropDownList;
DropDownListHelper.BindMember(ddl);

this.GridViewMemberAccount.EditIndex = e.NewEditIndex;
this.GridViewDataBind();

这样会报错,提示未将对象引用到对象的实例 找不到dropDownList

要先绑定GridView的数据再绑定DropDownList.

this.GridViewMemberAccount.EditIndex = e.NewEditIndex;
this.GridViewDataBind();

DropDownList ddl = this.GridViewMemberAccount.Rows[e.NewEditIndex].Cells[0].Controls[1] as DropDownList;
DropDownListHelper.BindMember(ddl);

但原因不 明, 不知道是不是没绑定数据前 控件是未被实例化?
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: