问题描述
嗨.. !!!
更新方法不起作用.当我单击编辑"时,它将允许编辑该特定行,但是当我更改值并单击更新"时,该行不会受到影响
我尝试了很多但没有找到答案
代码如下
受保护的void Gdordermgmt_updatecmd(对象发送者,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 =更新tbl_mst_Order" +
设置Revised_Quote_Amount =""+ txtrevisedqtamt.Text +",Received_Amount =""+ txtamtrecieved.Text +"''其中Order_ID =" + e.Item.ItemIndex +";
cmd.Parameters.Add(新SqlParameter("@ txtrevisedqtamt",SqlDbType.Text));
cmd.Parameters ["@ txtrevisedqtamt"].Value = tx.Text;
cmd.ExecuteNonQuery();
Gdordermgmt.EditItemIndex = -1;
Gdordermgmt.DataBind();
}
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();
}
推荐答案
这篇关于数据网格更新命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!