Updating gridview rows using sqldatasource

With these controls, it is now possible to access and do data operations without even writing a single line of code.Using this control is much straight forward and easier which doesn’t even require knowledge on programming.With these events, it is possible to do customizations and even implementing business rules dynamically during the databind operation.To cancel a databind, we can utilize the “onselecting” event which will be raised by Sql Data Source control during every database select operation.There is an event called “onselected” event which gets raised after every database select operations.This event exposes a property called Affected Rows that returns number of rows selected.Sql Data Source control exposes the Sql Command object that is being used in DB operation through the Sql Data Source Selecting Event Args object in On Selecting event.

In this article, we have seen some of the advance usages of Sql Data Source control which makes the control usage effective in those scenarios.

By default, when we configure the Sql Data Source control with a Databound control it will populate the data on the initial page load.

At times, we need to restrict the databind on initial page load and populate it in subsequent postbacks. Sql Data Source expose various events during the process of data binding to have a control on databinding.

Configure the Sql Data Source control through “Configure Data Source...” wizard to fetch the data from the Sql express database added to your solution.

Assign the Grid View’s Data Source ID property to the Sql Data Source control’s ID.

Search for updating gridview rows using sqldatasource:

updating gridview rows using sqldatasource-20

This calls for some extra coding from developer's end. As an example we are going to use Employees table of the Northwind database. Add three Bound Fields and a Command Field to the Grid View with the help of Fields dialog (see below).

Leave a Reply

Your email address will not be published. Required fields are marked *

One thought on “updating gridview rows using sqldatasource”