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