我想循环这段代码并保存选定的 CheckBoxList 项目。我该怎么做?
String insCmd = "Insert into Sale (Name, price) values (@Name, @price)";
SqlCommand insertUser = new SqlCommand(insCmd, myConnection);
insertUser.Parameters.AddWithValue("@Name", CheckBoxList1.SelectedItem.ToString());
insertUser.Parameters.AddWithValue("@price", Convert.ToDecimal(TextBox3.Text));
try
{
myConnection.Open();
insertUser.ExecuteNonQuery();
myConnection.Close();
}
catch (Exception er)
{
Response.Write("<script>alert('Error While Input')</script>");
}