Please help me with writing a Row Updating function in C#, I don't know how to grab the current field's value and also get the old value for one of keys (which is Project Name for editing) of the selected row. the idea wa to don't allow binding the grid view after a post back.
hello my problem was that my gridview editable controls heep their old values. this is due to the grid view binding in the page_load method after every post back.
We can't update a record until that record doesn't exist in the input type field (Text Box).
So first we need to move to an updateable row record in the Text Box.
In this article we will look at how to update or delete a record in a database table using a Grid View control.
The Grid View control is a tabular databound control but sometimes it is used like a spreadsheet control. NET 2.0 and is an improved version of the Data Grid control. We can use this to display data from a database and edit, sort and select the data.
When we edit a row in our Grid View and press the “Update” button, at some time it’s received in the Row Updating method.
Delete a Record We can delete a record from the database table by clicking on the delete button that is in the Delete column of the Grid View.
We first of all create a Stored Procedure that gets the Id of an employee as a parameter from the Grid View on whichever row the user clicked. In this event, first we get the datakey value that is the id of an employee of whichever row the user clicked and that id is passed as a parameter to the Stored Procedure. According to the above, in these three operations we use three events of the Grid View for each operation.
Row Updating event, doesn’t work as all samples say it should do.
All samples of course assume you’re doing everything in your page, but I have to do everything in my code-behind, because on forehand I don’t know what I’ll be binding to my Grid View.
The problem is, I’d very much like to do so, if ASP. But I can’t set a Data Source property or anything on the Sql Data Source!!! I probably have to read the cells on the Grid View of the selected row, find the controls, get the values from those and insert those into my Data Set.