Thursday, January 22, 2009

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
        List<String> output = new List<String>();
        foreach (ListItem listItem in Items)
            if (listItem.Selected)
        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);

No comments:

Post a Comment