我想在ASP.NET转发器ItemDataBound事件中执行等效的Eval(“field”),但我不确定将e.Item.DataItem转换为什么.数据源类型可能会有所不同,因为这是自定义控件中的可重用代码.那么如何通过字段名称(字符串)访问e.Item.DataItem中的字段?
理想情况下,我想做的事情如下:
protected void Repeater1_ItemDataBound(object sender,RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) { xxx item = (xxx)e.Item.DataItem; string fieldValue = item("fieldname"); } }
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。