1
Answer

CheckBoxList - programmatically setting Items as Checked

Ask a question
Gary King

Gary King

13y
17.6k
1
Hi,

As a simplified example, I have a CheckBoxList that contains 3 Items as follows:

<asp:CheckBoxList ID="cblColors" runat="server">

        <asp:ListItem>Red</asp:ListItem>

        <asp:ListItem>Green</asp:ListItem>

        <asp:ListItem>Blue</asp:ListItem>

</asp:CheckBoxList>


The result is written to single column (Colors) in my database and the some of the possible values could be "Red" or "Red,Green" or "Green,Blue" or "Red,Green,Blue"....and so on.

When I read the value from the database into a string "SelectedColors", how can I then use the value of "SelectedColors" to set the corresponding ListItems as Checked?


Thanks
Gary

Answers (1)