Subscribe | Alerts via Email
View All Quotes
“When I am working on a problem I never thing about the beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong.”
-R. Buckminster Fuller
<July 2010>
SunMonTueWedThuFriSat
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

©2010 Cal Zant
Sign In
Total Posts: 106
This Year: 5
This Month: 1
This Week: 0
Comments: 2

I have often times wanted to write something like CheckBoxList1.Items.Where(i => i.Selected).  Turns out you can't do that, because the Items property is a "specialized" collection.  But to get it to work all you have to do is cast it to a generic list of ListItems like this:

var selectedItems = CheckBoxList1.Items.Cast<ListItem>().Where(i => i.Selected)

The example above uses method syntax, but you could also use query syntac like this:

var selectedItems = from i in CheckBoxList1.Items.Cast<ListItem>()
                    where i.Selected
                    select i;

Monday, November 17, 2008 1:52:49 PM (Central Standard Time, UTC-06:00)  #