edit a row in gridview
-
hi friends,, i am trying to do edit the row in GridView .... this is the coding for updating System.Web.UI.WebControls.TextBox cName = new System.Web.UI.WebControls.TextBox(); cName = (TextBox)myDataGrid.Rows[e.RowIndex].FindControl("Contactname"); SqlConnection myConnection = new SqlConnection("Data Source=DAYAKAR\\sqlexpress; Initial Catalog=hospital;Integrated Security=true"); SqlCommand myCommand = new SqlCommand("SP_UpdatePerson", myConnection); myCommand.CommandType = CommandType.StoredProcedure; myCommand.Parameters.Add(new SqlParameter("@Contactname", SqlDbType.VarChar, 50)); myCommand.Parameters["@Contactname"].Value = cName.Text; myConnection.Open(); myCommand.ExecuteNonQuery(); myConnection.Close(); myDataGrid.EditIndex = -1; BindData(); in this i got error in cName = (TextBox)myDataGrid.Rows[e.RowIndex].FindControl("Contactname"); so i modified as TextBox txtName = (TextBox)CustomerGrid.Rows[e.RowIndex].FindControl("txtContactName"); even i am not getting the updated value... in the textbox.... so that i can update that value in the DB... kindly help me soooon...
-
hi friends,, i am trying to do edit the row in GridView .... this is the coding for updating System.Web.UI.WebControls.TextBox cName = new System.Web.UI.WebControls.TextBox(); cName = (TextBox)myDataGrid.Rows[e.RowIndex].FindControl("Contactname"); SqlConnection myConnection = new SqlConnection("Data Source=DAYAKAR\\sqlexpress; Initial Catalog=hospital;Integrated Security=true"); SqlCommand myCommand = new SqlCommand("SP_UpdatePerson", myConnection); myCommand.CommandType = CommandType.StoredProcedure; myCommand.Parameters.Add(new SqlParameter("@Contactname", SqlDbType.VarChar, 50)); myCommand.Parameters["@Contactname"].Value = cName.Text; myConnection.Open(); myCommand.ExecuteNonQuery(); myConnection.Close(); myDataGrid.EditIndex = -1; BindData(); in this i got error in cName = (TextBox)myDataGrid.Rows[e.RowIndex].FindControl("Contactname"); so i modified as TextBox txtName = (TextBox)CustomerGrid.Rows[e.RowIndex].FindControl("txtContactName"); even i am not getting the updated value... in the textbox.... so that i can update that value in the DB... kindly help me soooon...