Page 1 of 1

Change DataItem's in ListView on ItemDataBound Event

Posted: Tue 27 Apr 2010 14:35
by mabraham1
I'm trying to access a DataItem object during the ItemDataBound event in the 3.5 ListView control. I need to access the child object's properties. I'm using LINQ to retrieve the data.

Going by example, I'm unable to use the code the MS specifies here:
http://msdn.microsoft.com/en-us/library ... bound.aspx

The System.Data.DataRowView is not a valid cast, and I can't even get to the object doing something like this:
DataBinder.Eval(((System.Web.UI.WebControls.ListViewDataItem)e.Item), "Orderid")
OR this:
((System.Web.UI.WebControls.ListViewDataItem)e.Item).DataItem["Orderid"]

Please advise ASAP.

Posted: Thu 29 Apr 2010 08:23
by Shalex
Could you please send us a small test project with the DDL/DML script to reproduce the issue in our environment?