任何人都知道通过使用扩展
方法在列表框控件中
获取所有选定项目的平滑
方法?
而且,请不要犹豫,就如何获得这样的一个列表,因为最终所有的东西都使用一个循环来迭代项目,并找到所选的对象.
var selected = yourListBox.Items.GetSelectedItems();
//var selected = yourDropDownList.Items.GetSelectedItems();
//var selected = yourCheckBoxList.Items.GetSelectedItems();
//var selected = yourRadioButtonList.Items.GetSelectedItems();
public static class Extensions
{
public static IEnumerable<ListItem> GetSelectedItems(
this ListItemCollection items)
{
return items.OfType<ListItem>().Where(item => item.Selected);
}
}