数据网格更新命令 [英] update command of datagrid

查看:75
本文介绍了数据网格更新命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨.. !!!
更新方法不起作用.当我单击编辑"时,它将允许编辑该特定行,但是当我更改值并单击更新"时,该行不会受到影响

我尝试了很多但没有找到答案

代码如下
受保护的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();
}

推荐答案

您是否将Gdordermgmt_updatecmd事件与页面绑定了?
可能会丢失,并且AutoEventWireUp 不会设置为true.

看看这些工作示例:
http://www.codeproject.com/KB/aspnet/Edit_and_Delete_Data.aspx [ ^ ]
在Asp.Net GridView控件中简单地插入,选择,编辑,更新和删除 [
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[^]


这篇关于数据网格更新命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆