From Checkbox to Linq list

Just the Values of the Selected Items


List<string> selectedValues = chkMyList.Items.Cast<ListItem>()
   .Where(li => li.Selected)
   .Select(li => li.Value)
   .ToList();

Both Text and Value of Selected item into a listItem object


List<ListItem> selected = chkMyList.Items.Cast<ListItem>()
    .Where(li => li.Selected)
    .ToList();

Comments

Popular posts from this blog

Linq Exclude from separate list

Sorting Ascending and Descending

Linq Query Syntax vs Method Syntax