网格视图保管箱
我正在尝试使用 GridView 在 ASP.NET 中显示组件列表。我正在努力使其同时可编辑。其中一列是一个字符串,当用户编辑该行时应从列表中选择该字符串。
所以我尝试了以下操作:
- 将 BoundField 行转换为 ItemTemplate
- 将 dropbox 添加到 gridview 中的模板窗口
- 将所选项目绑定到字符串
此时,我收到错误,因为尚未在中设置列表项保管箱。所以我想我想知道的两件事是:
- 如何将保管箱中的项目分配给动态创建的选项列表?
- 如何使保管箱仅在编辑行时出现?
好的,我在 Visual Studio 中发现了“EditItemTemplate”字段,它回答了#2。
现在我发现保管箱有一个数据源字段,可以链接到数据对象中的属性,并保存选项列表。
I'm trying to use a GridView to display a list of components in ASP.NET. I'm trying to make it editable at the same time. One of the columns is a string that should be selected out of a list when the user edits the row.
So I've tried the following:
- Convert the BoundField row to an ItemTemplate
- Add a dropbox to the template window in the gridview
- bound the selecteditem to the string
At this point, I get an error because the list items haven't been set up in the dropbox. So I guess the two things I'm wondering are:
- How do I assign the items in the dropbox to a dynamically created list of options?
- How do I make the dropbox only appear when the row is being edited?
Ok so I've discovered the "EditItemTemplate" field in visual studio, that answers #2.
And now I've discovered that the dropbox has a datasource field which can be linked to a property in the data object, and that holds the options list.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在您的
DropDownList
中,您可以分配一个OnDataBinding
事件,然后使用该事件用自定义数据填充您的DropDownList
。示例:
然后在后面的代码中实现 OnDataBinding:
希望有帮助。
In your
DropDownList
you can assign aOnDataBinding
event and then us the event to fill yourDropDownList
with custom data.Example:
Then in your code behind implement the OnDataBinding:
Hope that helps.