skip to content »

doktorzelen.ru

Rowupdating old values

rowupdating old values-17

Create SQL Connection We need a connection with a Microsoft SQL Server database so we can access data and perform an operation on it.We define a connection in the web.config file and give a name to the connection string.

rowupdating old values-21rowupdating old values-16rowupdating old values-22

Then again we have to call that Bind Grid Data () method to bind data for the textboxes. You can leave a response, or trackback from your own site.All updated values are passed to the Stored Procedure.In the template field I will Place a label or some controls, So that it’s very easy to access those controls in the code behind by using Find Control method. Item Template is the content to display for the items in the Template Field.Secondly if you want to include a custom field (some button or link) in the same column it’s not possible.If we use proper command names for the buttons like “EDIT”, “DELETE”, “UPDATE”, “CANCEL” these will also trigger the appropriate Grid View Events.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.

Database Table Structure We are using an "EMPLOYEE" table so the "EMPLOYEE" table design is: Design of Grid View We design a Grid View with which we can perform update and delete operations.

Here we can update Name, Emp_Code and Emp_Age fields depending on the Id field of the "EMPLOYEE" table.

We use the Row Updating event of Grid View to update the record in the database table.

We get the Id value using the row index and another Text Box value is also retrieved.

Suppose if we are trying to hide primary key of our table, there is actually no need to hide. In the above Snippet you are seeing a label in Item Template that means whenever we are showing Grid View to the user Label will be visible to the user.