protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
cmd = new SqlCommand("update EmployeeMaster set Emp_Name=@Emp_Name,Category=@Category,Department=@Department,Qualification=@Qualification,Specialization=@Specialization,Salary=@Salary,Gender=@Gender,D_O_B=@D_O_B,Address=@Address,Pincode=@Pincode,Mobile=@Mobile,Email=@Email,M_Status=@M_Status,F_M_Name=@F_M_Name,BloodGroup=@BloodGroup,Allergy=@Allergy where Emp_Id=@Emp_Id", con);
cmd.Parameters.Add("@Emp_Id", SqlDbType.BigInt).Value =Convert.ToInt32( GridView1.DataKeys[e.RowIndex].Value);
cmd.Parameters.Add("@Emp_Name", SqlDbType.NVarChar).Value = ((TextBox)(GridView1.Rows[e.RowIndex].FindControl("TextBox18"))).Text;
cmd.Parameters.Add("@Category", SqlDbType.NVarChar).Value = ((TextBox)(GridView1.Rows[e.RowIndex].FindControl("TextBox19"))).Text;
cmd.Parameters.Add("@Department", SqlDbType.NVarChar).Value = ((TextBox)(GridView1.Rows[e.RowIndex].FindControl("TextBox20"))).Text;
cmd.Parameters.Add("@Qualification", SqlDbType.NVarChar).Value = ((TextBox)(GridView1.Rows[e.RowIndex].FindControl("TextBox21"))).Text;
cmd.Parameters.Add("@Specialization", SqlDbType.NVarChar).Value = ((TextBox)(GridView1.Rows[e.RowIndex].FindControl("TextBox22"))).Text;
cmd.Parameters.Add("@Salary", SqlDbType.BigInt).Value = Convert.ToInt32(((TextBox)(GridView1.Rows[e.RowIndex].FindControl("TextBox23"))).Text);
cmd.Parameters.Add("@Gender", SqlDbType.NVarChar).Value = ((TextBox)(GridView1.Rows[e.RowIndex].FindControl("TextBox24"))).Text;
cmd.Parameters.Add("@D_O_B", SqlDbType.NVarChar).Value = ((TextBox)(GridView1.Rows[e.RowIndex].FindControl("TextBox25"))).Text;
cmd.Parameters.Add("@Address", SqlDbType.NVarChar).Value = ((TextBox)(GridView1.Rows[e.RowIndex].FindControl("TextBox26"))).Text;
cmd.Parameters.Add("@Pincode", SqlDbType.NVarChar).Value = ((TextBox)(GridView1.Rows[e.RowIndex].FindControl("TextBox27"))).Text;
cmd.Parameters.Add("@Mobile", SqlDbType.NVarChar).Value = ((TextBox)(GridView1.Rows[e.RowIndex].FindControl("TextBox28"))).Text;
cmd.Parameters.Add("@Email", SqlDbType.NVarChar).Value = ((TextBox)(GridView1.Rows[e.RowIndex].FindControl("TextBox29"))).Text;
cmd.Parameters.Add("@M_Status", SqlDbType.NVarChar).Value = ((TextBox)(GridView1.Rows[e.RowIndex].FindControl("TextBox30"))).Text;
cmd.Parameters.Add("@F_M_Name", SqlDbType.NVarChar).Value = ((TextBox)(GridView1.Rows[e.RowIndex].FindControl("TextBox31"))).Text;
cmd.Parameters.Add("@BloodGroup", SqlDbType.NVarChar).Value = ((TextBox)(GridView1.Rows[e.RowIndex].FindControl("TextBox32"))).Text;
cmd.Parameters.Add("@Allergy", SqlDbType.NVarChar).Value = ((TextBox)(GridView1.Rows[e.RowIndex].FindControl("TextBox33"))).Text;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
Response.Write("<script language=javascript>alert('Record Updated successfully')</script>");
GridView1.EditIndex = -1;
showgrid();
}
No comments:
Post a Comment