Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected void btn1_Click(object sender, EventArgs e)
- {
- List<string> selected = CheckBoxList1.Items.Cast<ListItem>()
- .Where(li => li.Selected)
- .Select(li => li.Value)
- .ToList();
- using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
- {
- foreach (string item in selected)
- {
- String sqlUpdate = "insert into OficinasHasServicos values (8, @idservico)";
- SqlCommand command = new SqlCommand(sqlUpdate, con);
- command.Parameters.AddWithValue("@idservico", item.ToString());
- con.Open();
- command.ExecuteNonQuery();
- con.Close();
- lit1.Text += "added " + item.ToString() + "<br>";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement