如何获取repeater_itemdatabound事件中的一列值?
我在 ASP.NET 应用程序中使用中继器来显示数据库中的记录。绑定到转发器的数据源是数据表的记录。
如何获取中继器的 itemdatabound 事件中某一项的一列值?
我想获取名为“id”的列的值。如何在后端的repeater_itemdatabound事件中获取它?
I use repeater in my asp.net application to display records from database. The datasource that binded to repeater are records of a datatable.
How can I get one column value for an item in repeater's itemdatabound event?
I want to get a value of column called 'id'. How to get it in the repeater_itemdatabound event in backend?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 Repeaters ItemDataBound 事件中,您可以通过 e.Item.DataItem 属性提取绑定到项目的对象,然后执行以下操作:
In the Repeaters ItemDataBound event, you can extract the object bound to the item via the
e.Item.DataItem
property, and do:在项目数据绑定事件中,您可以访问事件参数(变量 e)
e.Item.DataItem 是当前正在绑定的记录。请务必将其转换为 DataRow 或绑定集合中项目的任何类型。
您可以访问 ID 列
In the item databound event you have access to the event arguments (variable e)
e.Item.DataItem is the record that is currently being bound. Be sure to cast it as a DataRow or whatever the type is of the item in the collection being bound.
You could access the ID column