DropDownList Part 4: Bind DropDownList To A List Of Objects
In this part of the tutorial we will bind a DropDownList control to a list of objects. This common practice if you are working with business objects that are mapped to the database table. We will create a business object call "Category" and create a list call "categories" in our .aspx page. One of the most commonly used server controls in ASP.NET is the DropDownList control. In this blog I will show you how to bind a list of objects to a DropDownList control. 1. Create a .aspx page 2. Click on the "Toolbox" panel 3. Drag the DropDownList control into a design surface 4. Create a connection string in the Web.Config file <connectionStrings> <add name="NorthwindConnectionString" connectionString="Data Source=(local); Initial Catalog=Northwind;Integrated Security=True" providerName="System.Data.SqlClient"/> </connectionStrings> 5. Create a new folder in your project call "BusinessObjects" th...