protected void gvDetails_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
int Id = Convert.ToInt32(gvDetails.DataKeys[e.RowIndex].Value.ToString());
TextBox txtPrinterID = (TextBox)gvDetails.Rows[e.RowIndex].FindControl("txtPrinterID");
string username = gvDetails.DataKeys[e.RowIndex].Values["Username"].ToString();
TextBox txtName = (TextBox)gvDetails.Rows[e.RowIndex].FindControl("txtName");
TextBox txtDepartment = (TextBox)gvDetails.Rows[e.RowIndex].FindControl("txtDepartment");
TextBox txtDescription = (TextBox)gvDetails.Rows[e.RowIndex].FindControl("txtDescription");
TextBox txtEmail = (TextBox)gvDetails.Rows[e.RowIndex].FindControl("txtEmail");
con.Open();
SqlCommand cmd = new SqlCommand("update Employee_Details set PrinterID='" + txtPrinterID.Text + "',Name='" + txtName.Text + "',Department='" + txtDepartment.Text + "',Description='" + txtDescription.Text + "',Email='" + txtEmail.Text + "' where Id=" + Id, con);
cmd.ExecuteNonQuery();
con.Close();
lblresult.ForeColor = Color.Green;
lblresult.Text = username + " Details Updated successfully";
gvDetails.EditIndex = -1;
BindEmployeeDetails();
}
protected void gvDetails_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
gvDetails.EditIndex = -1;
BindEmployeeDetails();
}<pre>
my code is this. is it wrong?