If I have a List(Of Guid) can I map those Guid's with a single Linq expression to a CheckboxList of values?
+1
A:
There's not enough information in your question. We need to know the relationship between the guids and checkboxes. Are the values in the checkbox list also guids, and you need to match them up to see which are selected? Is it some other object with a guid property. Do you need to know which checkboxes have corresponding guids in your list? Is there no relationship at all and you need to create one (just sequentially)? Is the last option, how will you store and maintain the relationship?
Okay, based on comments I think you want something like this:
Dim MyList As List(Of Guid) = GetYourGuidList()
Dim CheckBoxes As CheckBoxList = GetYourCheckBoxList()
For Each box As CheckBox In CheckBoxes.Items.Where(Function(c) MyList.Contains(c.Value))
box.Checked = True
Next box
Unfortunately I've had an emergency come up here and so this was a bit rushed. Sorry.
Joel Coehoorn
2009-12-17 21:15:51
Yes, the CheckBoxList of values are Guids, and the List(Of Guid) are a list of values that should be selected.
Micah Burnett
2009-12-17 21:36:45
Still not clear. Do you want to select/check the checkboxes, or do you want to verify that those checkboxes are selected. What do you expect for the result of the operation?
Joel Coehoorn
2009-12-17 22:06:42
To mark each ListItem as selected.
Micah Burnett
2009-12-18 15:52:55
You mean checked? gimme a few minutes to work up an edit...
Joel Coehoorn
2009-12-18 15:55:08