This tutorial shows how we can dynamically populate a dropdown menu from data pulled from a database. C# version.

It is often useful to allow users to select items from a dropdown list for input into a web form. However, this can be somewhat too limiting in certain situations.
This tutorial will show how we can dynamically populate a dropdown menu with records from a database.
First, we start by declaring the assembly reference:

In our Web.config, we declare the connection string:

The ASPX page will look something like this:

In the code-behind, we can create two methods and then call them on page load:

Download Source Files