Code
protected void RepeaterPosts_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
string postID = (DataBinder.Eval(e.Item.DataItem, "postid")).ToString();
DoSometing(postID);
}
这个典型的ItemDataBound()事件中,用了LINQ以后,就不能用(DataRowView)e.Row.DataItem了,然后通过drv["postid"]访问果然是容易,当时现在类型转换失败;我找了很多类型,包括List,IEnumerable都不可以,看来不是这条路。
最后看到一句话:Since we do not know what type to cast the DataItem to, we can use Reflection to retrieve the property. The DataBinder.Eval method already does this.