protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { GridViewRow row = GridView1.Rows[e.RowIndex]; TextBox ID = (TextBox)row.FindControl("TextBoxEditID"); TextBox node = (TextBox)row.FindControl("TextBoxEditNode"); TextBox title = (TextBox)row.FindControl("TextBoxEdittitle"); TextBox source = (TextBox)row.FindControl("TextBoxEditsource"); TextBox scope = (TextBox)row.FindControl("TextBoxEditscope"); //int IDD = Int32.Parse(GridView1.DataKeys[e.RowIndex].Value.ToString()); int IDD = Convert.ToInt32(ID.ToString()); string nod = node.Text; string tit = title.Text; string sou = source.Text; string scpe = scope.Text; Update(IDD, nod, tit, sou, scpe); } private void Update(int IDD, string nod, string tit, string sou, string scpe) { try { string query = "UPDATE ['2013 Projects$'] SET Node =@nod, Title =@tit, Source =@sou, Scope =@scpe, WHERE ID=@IDD"; con = new SqlConnection(connstring); cmd = new SqlCommand(query, con); cmd.Parameters.Add("@nod", SqlDbType.VarChar).Value = nod; cmd.Parameters.Add("@tit", SqlDbType.VarChar).Value = tit; cmd.Parameters.Add("@sou", SqlDbType.VarChar).Value = sou; cmd.Parameters.Add("@scpe", SqlDbType.VarChar).Value = scpe; con.Open(); cmd.ExecuteNonQuery(); con.Close(); GridView1.EditIndex = -1; data(); } catch (Exception ex) { throw ex; } }
@IDD
cmd.Parameters.Add("@IDD", SqlDbType.Int).Value = IDD;
con.Open();
cmd
onrowupdating="GridView1_RowUpdating"
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)