title: CheckBoxList C# Values from a SQL Server database separated by ":"
body: <p>I have a <code>CheckBoxList</code> that needs to be populated from a SQL Server database that is separated by <code>:</code>.</p>
  
  <p>aspx page</p>
  
  <pre><code>&lt;asp:CheckBoxList ID="chkTopics" runat="server" CssClass="ChkList"&gt;
   &lt;asp:ListItem Value="ABC"&gt;ABC&lt;/asp:ListItem&gt;
   &lt;asp:ListItem Value="D-E-F"&gt;D-E-F&lt;/asp:ListItem&gt;
   &lt;asp:ListItem Value="GHI"&gt;GHI&lt;/asp:ListItem&gt;
   &lt;asp:ListItem Value="J,K,L"&gt;J,K,L&lt;/asp:ListItem&gt;
   &lt;asp:ListItem Value="MNO"&gt;MNO&lt;/asp:ListItem&gt;
   &lt;asp:ListItem Value="PQR"&gt;PQR&lt;/asp:ListItem&gt;
  &lt;/asp:CheckBoxList&gt;
  </code></pre>
  
  <p>.cs page on what how I am getting the values:</p>
  
  <pre><code>SqlConnection conn = null;
  conn = new SqlConnection(conn_string);
  
  SqlCommand sqlCommand = new SqlCommand("aspnet_GetAnswers", conn);
  sqlCommand.CommandType = CommandType.StoredProcedure;
  
  conn.Open();
  
  SqlDataReader rdr = sqlCommand.ExecuteReader();
  
  if (rdr.Read())
  {
    FirstName.Text = rdr.GetValue(2).ToString();
    LastName.Text = rdr.GetValue(3).ToString();
   --&gt; Putting the Code here to read the values and check the values that match.
  }
  
  rdr.Close();
  conn.Close();
  conn.Dispose();
  </code></pre>
  
  <p>From the Database:</p>
  
  <blockquote>
    <p>rdr.GetValue(9).ToString();</p>
    
    <p>ABC:GHI:J,K,L:</p>
  </blockquote>