views:

135

answers:

2

Hi,

At the moment I have ResultsCollection = List<MyDataStructure>; which is then analysed with LINQ using something like:

var OrderedData = from tc in ResultsCollection
...
select new { myLink = g.Key, Count = g.Count(), First = g.First() };

At the moment I have a Repeater that is deifned using:

myRepeater.DataSource = ResultsCollection;
myRepeater.DataBind();

Instead of binding my generic List, I would like to bind my LINQ collection instead. Only problem here is that the generic nature of the LINQ object means that DataSource cannot check and display the properties defined in MyDataStructure

How can I bind my LINQ query output to myRepeater?

Thanks!

+2  A: 

The only issue is that in Visual Studio you can't see the properties. This is because Visual Studio can't figure out at design time an anonymous class. It doesn't matter though, they are easy to figure out. For example the myLink field would simply be:

 <%# Eval("myLink") %> 

in your repeater.

Keltex
Aha! Yep that's the one, thanks @Keltex ! Using templates has worked out ok after a steepish learning curve recently :)
AlexW
A: 

I'd recommend reading up a bit on asp.net DataBinding. Here is a decent article. They use a FormView instead of a Repeater but the concept is essentially the same.

Abe Miessler