Ok so its not exactly an Umbraco API problem, but I am using Umbraco to build the site AND this is using Linq2Umbraco.
I have a GridView which I have a List<T> bound to using Linq2Umbraco - I want to be able to allow filter of the data based on multiple CheckBoxLists.
For arguments sake let's say I have a List of Jobs, and I want to filter the jobs by a code - So I would have a CheckBoxList like
C#
ASP.NET
php
F#
etc..
If someone selects multiple codes, how do you pass the values into a List to rebind to the GridView? Is there a way to pass values as an array? Or maybe a comma separated string? Or do you have to loop through manually?
Passing CheckboxList Values To List<T>
Ok so its not exactly an Umbraco API problem, but I am using Umbraco to build the site AND this is using Linq2Umbraco.
I have a GridView which I have a List<T> bound to using Linq2Umbraco - I want to be able to allow filter of the data based on multiple CheckBoxLists.
For arguments sake let's say I have a List of Jobs, and I want to filter the jobs by a code - So I would have a CheckBoxList like
If someone selects multiple codes, how do you pass the values into a List to rebind to the GridView? Is there a way to pass values as an array? Or maybe a comma separated string? Or do you have to loop through manually?
If you want to get all the selected values of a list, you can use a cunning bit of linq to get them all:
IEnumerable<string> selectedBits = from ListItem item in YourListObjectNameHere.Items
where item.Selected
select item.Value;
Then to get it as a comma separated string say:
category.IncludedManufacturers = string.Join(",", selectedBits .ToArray());
:)
is working on a reply...