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.
In this chapter, we are going add a DropDownList in the gridview control.
In this article I have used Microsoft's Pubs database for sample data. You can download it free from the following link.
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.
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
- ASP.NET Simple GridView
- Sorting , Paging and AutoGenerateColumns
- ASP.NET GridView Editing
- ASP.NET GridView Delete
- Create Gridview at runtime
- Gridview - Add, Edit and delete
- Gridview export to Excel
- Gridview export to CSV
- GridView summary on Footer
- Subtotal row in Gridview
- SubTotal and GrandTotal in GridView
- Create Gridview without database
- GridView from Stored Procedure
- How to create Gridview Popup Form
- How to create a Blank row in gridview
- Nested GridView in ASP.NET
- Freeze Gridview Header row, Scroll in GridView
- Auto Generate Row Number in GridView
- Image between GridView rows
- How to select a row in gridview
- Checkbox in ASP.NET GridView Control