Anyone know of a smooth way to get all of the selected items in a listbox control by using extension methods?
And, please, spare me the argument of
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 GetSelectedItems(
this ListItemCollection items)
{
return items.OfType().Where(item => item.Selected);
}
}