Updating gridview rows using sqldatasource

In my previous post i explained how to Delete multiple rows in Gridview with checkbox and delete confirmation Javascript In the code behnd i've created a String Builder to store update commands separated by ; for records to be edited.

than looping through gridview rows to find checked rows, then find the value in textbox using find Control. Populating dropdown based on the selection of first drop down in Details View using Find Control and Item Template 2.

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

In order to develop a test web form create a new web site in VS. Set various properties of the Bound Fields as shown in the following table: Here, we call Bind Grid() method if the web form is being served as a result of first request.

I'm pretty sure I need to change my Update Command of the sql Data Source that feeds my Grid View, and/or add code to my dropdown box's but I'm at a loss of how to do that.

updating gridview rows using sqldatasource-77updating gridview rows using sqldatasource-4updating gridview rows using sqldatasource-30

Like all data source controls, the Sql Data Source control can be declaratively bound to any data-bound control that supports the Data Source ID property.After setting the cpnnectionstring, we are going to bind the Drop Down List to the city column of the stores table in the pubs database from In order to bind a Drop Down List, we need a Drop Down List control and an Sql Data Source to connect the datafield to the database.We discussed about inserting, updating and deleting data from gridview, using sqldatasource control in Part 23.In Part 24, we discussed about achievieng the same, using Object Data Source control.