WebDropDown™ can be bound to a SQL Data Source using the Data Source editor.WebDropDown allows you to show more than one column through the use of templating.
In this topic, you will bind WebDropDown to a single column of the Customers table from the Northwind database.
You will learn how to bind WebDropDown to a SQL Data Source.
Create an ASP.NET web page.
Drag a ScriptManager component from the Microsoft® Visual Studio™ toolbox onto the page.
Drag a WebDropDown control onto the page.
Drag a SqlDataSource component onto the page.
Click the SqlDataSource component’s smart tag and select Configure Data Source. The Configure Data Source configuration wizard appears.
Click New Connection… to configure the connection string. The Add Connection dialog appears.
Set the server name to the server you are using, .\SQLEXPRESS in this case. Set the database to Northwind.
Click Ok. You are returned to the Configure Connection screen.
Click Next.
Select Specify Columns from a Table or View and do the following:
Choose the Customers table from the drop-down list.
In the Columns section, select CompanyName to display the column.
Click Next.
Test your query to make sure SqlDataSource retrieves your data.
Click Finish to close the configuration wizard. SqlDataSource is set up to retrieve the CompanyName of the Customers table from the Northwind database.
In the Property window for WebDropDown, set the DataSourceID property to be the id of the SqlDataSource component.
Set the TextField property to CompanyName.
Save and run the application. WebDropDown displays the list of company names similar to the following image: