tags:

views:

66

answers:

1

I'm working at the aspx page, and the following code is inserted in a Repeater control:

<%# ((System.Collections.Generic.List<double>)DataBinder.Eval(Container.DataItem, "BookPrices")).Max() %>

Brings up the following error: 'System.Collections.Generic.List<double>' does not contain a definition for 'Max'

List does have an method of Max(), so I'm possibly messing up my code somehow. What is my problem? BookPrices is a list<double> object, which I'd like to print it's maximum value.

P.S. You guys are great! I didn't find answers for many of my questions on the web. You really are life savers. Thank you very much! :)

+1  A: 

Did you make sure to import System.Linq?

List<T> does not actually have a Max method. Instead Max most often binds to the extension method Enumerable.Max. Linq needs to be imported in order for this to work.

JaredPar
I'm working at the `aspx` page, I can't import a thing. This code is inserted in a `Repeater` control. BTW I've used list.max few times and i never used `using System.Linq`.
iTayb
In the aspx page you do this by <%@ Import Namespace="System.Linq" %>
MPritch
Thank you!~ it worked! :D
iTayb