相关疑难解决方法(0)

LINQ:使用Lambda表达式获取CheckBoxList的所有选定值

考虑一种情况,您想要检索一个ListIEnumerable多个所选复选框的值<asp:CheckBoxList>.

这是当前的实现:

IEnumerable<int> allChecked = (from item in chkBoxList.Items.Cast<ListItem>() 
                               where item.Selected 
                               select int.Parse(item.Value));
Run Code Online (Sandbox Code Playgroud)

问题:如何使用lambda表达式或lambda语法改进此LINQ查询?

c# linq asp.net webforms

36
推荐指数
2
解决办法
4万
查看次数

标签 统计

asp.net ×1

c# ×1

linq ×1

webforms ×1