Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try
- {
- foreach (GridViewRow row in GridView1.Rows)
- {
- if (row.RowType == DataControlRowType.DataRow)
- {
- CheckBox chkRow = (row.Cells[0].FindControl("CheckBox1") as CheckBox);
- if (chkRow.Checked)
- {
- int Id = Convert.ToInt32(GridView1.DataKeys[row.RowIndex].Value.ToString());
- SqlCommand cmd = new SqlCommand("UPDATE dbo.registo SET nome='" + txtNome.Text + "',apelido='" + txtApelido.Text + "',titulo='" + txtTitulo.Text + "',cidade='" + txtCidade.Text + "',pais='" + txtPais.Text + "',Imagem='" + "~/imagens/" + FileUpload1.FileName + "' WHERE Id=@id", conn);
- cmd.Parameters.Add("@Id", SqlDbType.Int).Value = Id.ToString();
- cmd.ExecuteNonQuery();
- Response.Redirect("Main.aspx");
- }
- }
- }
- }
- catch
- {
- comm.CommandType = System.Data.CommandType.Text;
- comm.CommandText = "INSERT INTO Registo(Id,Nome,Apelido,Titulo,Cidade,Pais,Imagem) VALUES ('" + id + "','" + txtNome.Text + "','" + txtApelido.Text + "','" + txtTitulo.Text + "','" + txtCidade.Text + "','" + txtPais.Text + "','" + local.ToString() + "')";
- comm.ExecuteNonQuery();
- Atualizar();
- Response.Redirect("Main.aspx");
- }
Add Comment
Please, Sign In to add comment