DataGrid Update doesn't update
-
Hey all, any help would be appreciated. I have written a webform that has a datagrid. I am trying to get it to update but it will not update the changes. My code is listed below please help. I have no errors: Whats happens is the eventArgs does not pick up the changes but only the old values. Thanks public void UpdateCommand(Object sender, DataGridCommandEventArgs e) { //Retrieve items from Grid. string custID = ((TextBox)(e.Item.Cells[0].Controls[0])).Text; string cgARName = ((TextBox)(e.Item.Cells[1].Controls[0])).Text; string arPrice = ((TextBox)(e.Item.Cells[2].Controls[0])).Text; string arDesc = ((TextBox)(e.Item.Cells[3].Controls[0])).Text; arPrice = arPrice.Substring(1, arPrice.Length -1); double cost = double.Parse( arPrice ); //SQL Update Information SqlConnection sqlCon = new SqlConnection("myconnection"); string update = "UPDATE ActionRequestitems SET actionName = '" + cgARName + "',actioncost =" + cost + ",description = '" + arDesc + "' WHERE actionid = '" + "1" + "'"; sqlCon.Open(); SqlCommand myCommand = new SqlCommand(update); myCommand.Connection = sqlCon; myCommand.ExecuteNonQuery(); myCommand.Connection.Close(); sqlCon.Close(); // Reset the edit mode for the current item MyGrid.EditItemIndex = -1; // Refresh the grid BuildDataGrid(); }
-
Hey all, any help would be appreciated. I have written a webform that has a datagrid. I am trying to get it to update but it will not update the changes. My code is listed below please help. I have no errors: Whats happens is the eventArgs does not pick up the changes but only the old values. Thanks public void UpdateCommand(Object sender, DataGridCommandEventArgs e) { //Retrieve items from Grid. string custID = ((TextBox)(e.Item.Cells[0].Controls[0])).Text; string cgARName = ((TextBox)(e.Item.Cells[1].Controls[0])).Text; string arPrice = ((TextBox)(e.Item.Cells[2].Controls[0])).Text; string arDesc = ((TextBox)(e.Item.Cells[3].Controls[0])).Text; arPrice = arPrice.Substring(1, arPrice.Length -1); double cost = double.Parse( arPrice ); //SQL Update Information SqlConnection sqlCon = new SqlConnection("myconnection"); string update = "UPDATE ActionRequestitems SET actionName = '" + cgARName + "',actioncost =" + cost + ",description = '" + arDesc + "' WHERE actionid = '" + "1" + "'"; sqlCon.Open(); SqlCommand myCommand = new SqlCommand(update); myCommand.Connection = sqlCon; myCommand.ExecuteNonQuery(); myCommand.Connection.Close(); sqlCon.Close(); // Reset the edit mode for the current item MyGrid.EditItemIndex = -1; // Refresh the grid BuildDataGrid(); }
what do you have in BuildDataGrid method Bhaskara
-
what do you have in BuildDataGrid method Bhaskara