Adding To CheckBoxList

I always seem to be subclassing the standard .NET web controls and adding my own little features. Here is an enhancement that I made to CheckBoxList:
public String[] SelectedValues
{
    get
    {
        List<String> output = new List<String>();
        foreach (ListItem listItem in Items)
            if (listItem.Selected)
                output.Add(listItem.Value);
        return (output.ToArray());
    }
}
Now that I have this method I can convert the CheckBoxList to a CSV like this:
String csv = String.Join(",", checkBoxList1.SelectedValues);
{6230289B-5BEE-409e-932A-2F01FA407A92}

Comments

Popular posts from this blog

Simple WP7 Mango App for Background Tasks, Toast, and Tiles: Code Explanation

Yet once more into the breech (of altered programming logic)

How to convert SVG data to a Png Image file Using InkScape