I have a CheckBoxList that needs to be populated from a SQL Server database that is separated by :.
aspx page
<asp:CheckBoxList ID="chkTopics" runat="server" CssClass="ChkList">
<asp:ListItem Value="ABC">ABC</asp:ListItem>
<asp:ListItem Value="D-E-F">D-E-F</asp:ListItem>
<asp:ListItem Value="GHI">GHI</asp:ListItem>
<asp:ListItem Value="J,K,L">J,K,L</asp:ListItem>
<asp:ListItem Value="MNO">MNO</asp:ListItem>
<asp:ListItem Value="PQR">PQR</asp:ListItem>
</asp:CheckBoxList>
.cs page on what how I am getting the values:
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();
--> Putting the Code here to read the values and check the values that match.
}
rdr.Close();
conn.Close();
conn.Dispose();
From the Database:
rdr.GetValue(9).ToString();
ABC:GHI:J,K,L: