I have a gridview and would like to update one of the columns within the gridview.

I want to be able to search for the product id of an item and when the item is displayed the user can enter a number to a textbox. When the submit button is clicked I want the number in the textbox to be added to the number already in one of the database columns (stock).

E.g - The number in the database column for the particular product is 10.
User enters 5 into text box then clicks submit.
New value in stock column for product is 15.

Hope i have explained clearly enough.

I have the search working so its just the update I'm having difficulty with.

Thanks for any help.

7 Years
Discussion Span
Last Post by leahrose87

I assume that your data displayed in your gridview is from a database.
To make sure you can update the value in your gridview,
you must first update your database using this syntax:

Update Table_name set stocks="value" where productid="theSpecifiedValue"

Then you must create a separate method that will load the value of your gridview.
I hope you already did because your search is working as you say.
When the the submit button is clicked, you can used the syntax on how to update the value in the database and call your method that will show your value in the gridview.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.