Click here to Skip to main content
15,886,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Comments
Suvendu Shekhar Giri 23-Jul-15 5:00am    
What is your datasource?
Can share the code block where you are binding the gridview?

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

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


SQL
select max(ID) from  [Trail]
this query return lastly added row.

Regards
Aravind
 
Share this answer
 
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();
}
 
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