Click here to Skip to main content
15,897,968 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi..!!!
update method is not working. when i click on edit it will allow to edit me that particular row but when i change the value & click on update the row is not getting affected

i tried a lot but not finding answer

code is as below
protected void Gdordermgmt_updatecmd(object sender, DataGridCommandEventArgs e)
{
TextBox txtamtrecieved = (TextBox)e.Item.FindControl("txtamtrecieved");
TextBox txtrevisedqtamt = (TextBox)e.Item.FindControl("txtrevisedqtamt");
TextBox tx = new TextBox();
tx = (TextBox)e.Item.Cells[8].Controls[0];
// cmd.CommandType = CommandType.Text;
cmd.CommandText ="Update tbl_mst_Order" +
" Set Revised_Quote_Amount= '" + txtrevisedqtamt.Text + "', Received_Amount='" + txtamtrecieved.Text + "'where Order_ID='"+ e.Item.ItemIndex +"'";
cmd.Parameters.Add(new SqlParameter("@txtrevisedqtamt", SqlDbType.Text));
cmd.Parameters["@txtrevisedqtamt"].Value = tx.Text;
cmd.ExecuteNonQuery();
Gdordermgmt.EditItemIndex = -1;
Gdordermgmt.DataBind();
}
Posted

1 solution

Did you bind the Gdordermgmt_updatecmd event with the page?
Might be missed and AutoEventWireUp not set to true.

Have a look at these working samples:
http://www.codeproject.com/KB/aspnet/Edit_and_Delete_Data.aspx[^]
Simple Insert, Select, Edit, Update and Delete in Asp.Net GridView control[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900