Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting DataBinder Item's max value

Tags:

c#

asp.net

eval

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! :)

like image 457
iTayb Avatar asked Feb 02 '26 04:02

iTayb


1 Answers

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.

like image 128
JaredPar Avatar answered Feb 03 '26 18:02

JaredPar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!