I am binding a grid to a linq statement which creates an anonymous type class for the data. When I try and get to the data in the InitializeRow event, I'm having a problem casting the row properly. If I create a class for the linq results, it's easy, but I don't want to create a new class for every linq statement. For example:
var rows= from r in db.table select new {id=xxxx, value=yyyy} <-- this creates an anonymous type versus....
var rows= from r in db.table select rowclass new {id=xxxx, value=yyyy}
class rowclass {int id, string yyyy}, which gives me a collection of rowclass.
Any ideas on how to access the data when using anonymous classes? thanks.
Not sure exactly what you are trying to do, but I have some code which needs to get access to the row data in the InitializeRow event.
I simply use code like
dim strName as string = e.row.Cells(0).Text
This returns the string in the first column of the row.
This code works for a LINQ query from both XML and SQL.
Not sure if this of any help
Alex
I need to get to some of the data columns that are not bound to grid columns. So i need to use e.Data instead of e.Row.