Gary King

Gary King

  • NA
  • 83
  • 209.2k

CheckBoxList - programmatically setting Items as Checked

Jul 7 2011 5:00 AM
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 (2)