在 rowediting 事件中设置 gridview 中的下拉列表
尝试让 findcontrol 工作,以便我可以设置模板字段中下拉列表的默认值,但我没有运气。我做错了什么吗?
Dim drdList As DropDownList
For Each row As GridViewRow In gridviewComputer.Rows
drdList = gridviewComputer.Rows(e.NewEditIndex).FindControl("statusDropDown")
Next
Trying to get the findcontrol to work so I can set the default value of the dropdownlist I have in a template field, but I'm having no luck. Am I doing something wrong?
Dim drdList As DropDownList
For Each row As GridViewRow In gridviewComputer.Rows
drdList = gridviewComputer.Rows(e.NewEditIndex).FindControl("statusDropDown")
Next
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
找到了更简单的方法。
进入 gridview 模板编辑,然后在 EditItemTemplate 下声明下拉列表,我选择了“编辑数据绑定”。刷新架构,然后我可以将 SelectedValue 属性设置为 gridviews 数据源的相应字段。 (实际上只是在代码表达式中填写“Bind("columnName")”。)问题解决了!
Found an easier way.
Go into the gridview template editing, then under the EditItemTemplate, where I had the dropdownlist declared I selected Edit DataBindings. Refresh the Schema, then I was able to set the SelectedValue property to the corresponding field of my gridviews datasource. (Which really just fills in "Bind("columnName")" in the Code expression.) Problem solved!