I'm setting the DataSource of an ASP.NET repeater as follows:
rptTargets.DataSource = from t in DB.SalesTargets select new { t.Target, t.SalesRep.RepName };
Now, in the repeater's OnDataBound event, how can I retrieve the RepName and Target properties from the anonymous type contained in e.Item.DataItem?
Many Thanks
You can use DataBinder.Eval:
string repName = (string)DataBinder.Eval(e.Item.DataItem, "RepName");
string target = (string)DataBinder.Eval(e.Item.DataItem, "Target");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With