如何在Asp.net获得所选项目的CheckBoxList
问题描述:
我在page.is那里的CheckBoxList任何方式使用来获取所有选定项的值LINQ?
I have a CheckBoxList in my page.is there any way to get all selected item values using linq?
什么是获得的CheckBoxList选中的项值的最佳方式是什么?
what is the best way to get selected item values in CheckBoxList?
答
您可以去这所采取的复选框列表中的项目,并将其转换为ListItems的,并从该集合获取那些谁被选中,是这样的:
You could go about this by taking the items of the checkbox list and converting them to ListItems and from that collection fetch those who is selected, like this:
var selectedItems = yourCheckboxList.Items.Cast<ListItem>().Where(x => x.Selected);