Net-informations.com
SiteMap  | About    

DropDownList in GridView



The GridView allows editing on a row-by-row basis. In the previous lesson we saw how to edit a Gridview using SqlDataSource.

Edit GridView

In this chapter, we are going add a DropDownList in the gridview control.

add dropdownlist in gridview

Download Database

In this article I have used Microsoft's Pubs database for sample data. You can download it free from the following link.

Download

After setting up the database, we should configure the Web.Config File for connectionStrings. Add the following code to the Web.Config File.

After setting the cpnnectionstring, we are going to bind the DropDownList to the city column of the stores table in the pubs database from default.aspx. In order to bind a DropDownList, we need a DropDownList control and an SqlDataSource to connect the datafield to the database. The following code create a TemplateField for city column in the webpage.

dropdownlist in gridview

Also we need another SqlDataSource to connect the DropDownList to the database.

Copy and paste the following full source code for add a DropDownList to asp.net gridview

Default.aspx








net-informations.com (C) 2019    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.