Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
535
Binding grid to LINQ
posted

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.