我正在尝试将一个实现了ICollection、IEnumerable和IList接口的集合绑定到一个asp.net重复器中。这个集合的名称为CustomCollection。所以我将重复器的数据源设置为该集合,如下所示:
rptRepeater.DataSource = customCollection;
rptRepeater.Databind();
然后,在ItemDataBound事件中,我尝试访问DataItem对象,如下所示:
void rptRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e){
object obj = e.Item.DataItem; // DataItem is null for some reason
}
由于某些原因,e.Item.DataItem对象为空。有人知道为什么会这样,或者我该如何获取要绑定到Repeater的集合中的对象吗?
谢谢!