Multiple select from checkboxes using c#
<p>Hy..I have a checkbox with 5 choices. I want to insert the checked values into one table separated by a ' , '.Here is my code:</p>

<pre><code>        string str = string.Empty;

        foreach (ListItem item in this.checkbox1.Items)
       {
            if (item.Selected)
           {
                str = str + ",";
           }
        }

        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["chestionar"].ConnectionString);
        SqlCommand cmd = new SqlCommand("INSERT INTO Raspunsuri Values('" + str + "',@cnp,@data,'10')", con);

        cmd.Parameters.AddWithValue("@cnp", Session["sesiune_cnp"]);
        cmd.Parameters.AddWithValue("@data", DateTime.Now.ToLocalTime());


        try
        {
            con.Open();
            cmd.ExecuteNonQuery();
            Response.Redirect("User11.aspx");
        }

        catch (Exception ex)
        {
            Console.WriteLine("Error:" + ex);
        }
        finally
        {
            con.Close();
        }
</code></pre>

<p>My problem is that when I hit the insert button it doesn't insert the values that the user checked.I must assign to string str a value.What is that value??</p>
