获取DataBinder Item的最大值

发布于 2024-08-27 07:29:01 字数 485 浏览 3 评论 0原文

我正在 aspx 页面上工作,并将以下代码插入到 Repeater 控件中:

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

出现以下错误:'System.Collections.Generic。列表<双>'不包含“Max”的定义

列表确实有一个Max()方法,所以我可能会以某种方式弄乱我的代码。我的问题是什么? BookPrices 是一个 list 对象,我想打印它的最大值。

PS你们太棒了!我在网上没有找到许多问题的答案。你们确实是救星。非常感谢! :)

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情释 2024-09-03 07:29:01

您确定导入了 System.Linq 吗?

List 实际上没有 Max 方法。相反,Max 最常绑定到扩展方法 Enumerable.Max。需要导入 Linq 才能使其工作。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文