使用asp.net使用gridview中显示的数据影响最后一个输入值 [英] affect the last enter value with the data that is shown in the gridview using asp.net

查看:67
本文介绍了使用asp.net使用gridview中显示的数据影响最后一个输入值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用asp.net使用gridview中显示的数据影响最后一个输入值



i将girdview中的数据显示为



商品价格数量



pen 10 1



pencil 20 1







如果我在文本框中输入值为2我需要更改铅笔数量as 2





商品价格数量



pen 10 1 br />


pencil 20 2

affect the last enter value with the data that is shown in the gridview using asp.net

i show the data in the girdview as

item price qty

pen 10 1

pencil 20 1



if i enter the value in the textbox as 2 i need to change the pencil quantity as 2


item price qty

pen 10 1

pencil 20 2

推荐答案

您好
您需要指定需要更新的项目数量,如果你更新最新的条目,那么你不能再更新旧值了,所以最好使用条件更新数值。



如果你想更新最后添加的值,那么你已经在该表中设置了id列并将其作为标识yes,因此一旦在该表中插入值,它就会自动增加id值,你不需要插入id值,然后当你更新使用以下查询



Hi U need to specify which item qty need to update,if u update latest entry,then u can't update old values any more,so better to use where condition for update qty value.

If u want to update lastly added value,then u have set id column in that table and make as identity "yes" so it automatic increment id value once insert value in that table,u no need to insert id value,then when u update use following query

Update [Trail] set qty='"+ textbox.text.trim +"' where ID= (select max(ID) from  [Trail])







select max(ID) from  [Trail]

此查询返回最后添加的行。



问候

Aravind

this query return lastly added row.

Regards
Aravind


如果您想在gridview中显示受影响的结果,只需更新即可。

你打电话给DataBp und()更新记录代码末尾的网格视图方法。

像这样。



protectd void btnUpdate_Click(object sender, EventArgs e)

{

试试

{

//这里是你更新记录的代码

}

Catch(例外情况)

{



}

gridView1.DataBound();

}
If you want to show the affected result in the gridview just with updating.
You shoud call the DataBpund() Method of grid view at end of the code of update record.
like this.

protectd void btnUpdate_Click(object sender, EventArgs e)
{
try
{
//Here your code for Update record
}
Catch(Exception ex)
{

}
gridView1.DataBound();
}


这篇关于使用asp.net使用gridview中显示的数据影响最后一个输入值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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