In rowupdating

Now we access this connection string on the page so we can open a connection with the relation database. The first one accesses the connection string and the other is for the SQL connection.

Now we define a method for opening a connection with the relation database and returns a SQL connection object depending on the connection string that is passed as a parameter of the Sql Connection class constructor.

the good old problem of getting the data from the row that is being currently edited within a Grid View. Accessing the "Controls": This method gets you access to the control in the Grid View, which might be useful based on what you are doing.

Obviously the simplest method is to use Data Key Names on the Grid View and then you should have the data in your Grid View Update Event Args as part of e. (In the following example, I cast to a Check Box as I know I have a checkbox at the col Index You Are Interested In - you should cast to whatever control you have in that column).

Check out what I’m trying to do, maybe you can help?

First, I load up some data: After that, I’m doing some work to make my Grid View look beautifull, adding all columns by hand.

Editing the Grid View control can be an incredibly easy feature to add for certain database tables, especially those who have no foreign key associated and can easily be edited through the use of a standard Text Box web control as shown in the figure below: 1.

in rowupdating-44

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.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.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.

Leave a Reply