下拉列表中的最大值 - ASP.NET

本文关键字:ASP NET 最大值 下拉列表 | 更新日期: 2023-09-27 18:30:24

如何获得DropDownList值的最大值,ASP.NETC#

有什么方法还是我应该手动获取?

下拉列表中的最大值 - ASP.NET

int maxValue = DropDownList1.Items.Cast<ListItem>().Select(item => int.Parse(item.Value)).Max();

DropDownList1.Items.Cast<ListItem>().Max(j => j.Value) // For string comparison

DropDownList1.Items.Cast<ListItem>().Max(j => int.Parse(j.Value)) // If you want max int