Dhimesh Parmar

Dhimesh Parmar

  • NA
  • 126
  • 14.5k

i can'n perform record update using RowUpdating in gridview?

Mar 1 2018 9:14 PM
 
my code like there
 
and also file are atteched with db script and table code:
Please Any One Can Help Me.... 
------------------------------------------------------------------------------------------------------------------------ 
 
protected void gridStud_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
LinkButton btn = (LinkButton)gridStud.Rows[e.RowIndex].FindControl("linkUpdate");
int studentId = Convert.ToInt32(gridStud.DataKeys[e.RowIndex].Value.ToString());
TextBox txtStudName = (TextBox)gridStud.Rows[e.RowIndex].FindControl("txtStud");
RadioButton rd1 = (RadioButton)gridStud.Rows[e.RowIndex].FindControl("RadioButton3");
RadioButton rd2 = (RadioButton)gridStud.Rows[e.RowIndex].FindControl("RadioButton4");
TextBox txtBirthdate = (TextBox)gridStud.Rows[e.RowIndex].FindControl("txtDate");
TextBox txtEmail = (TextBox)gridStud.Rows[e.RowIndex].FindControl("txtEmail");
TextBox txtMobile = (TextBox)gridStud.Rows[e.RowIndex].FindControl("txtmob");
studentCommon c = new studentCommon();
SqlCommand cmd = new SqlCommand("studIUD");
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("StatementType", "UPDATE");
cmd.Parameters.AddWithValue("studentId", bal.studentId);
cmd.Parameters.AddWithValue("name", bal.name);
if (rd1.Checked)
{
cmd.Parameters.AddWithValue(bal.gender, "Male");
}
else
{
cmd.Parameters.AddWithValue(bal.gender, "Female");
}
cmd.Parameters.AddWithValue("brithDate", bal.brithDate);
cmd.Parameters.AddWithValue("emailid", bal.emailid);
cmd.Parameters.AddWithValue("mobilenumber", bal.mobilenumber);
c.ExecuteNonQueryByCommand(cmd);
gridStud.EditIndex = -1;
binddata();
}
 

Attachment: GridFun_(2).zip

Answers (1)