O'Reilly logo

ASP.NET by Example by Steven A. Smith

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Populating ListBoxes

One of the most common tasks you will encounter with using WebControls is populating their values from a data source. DropDownList, in particular, is one of the controls that most commonly needs to be populated from a data source of some kind. To wrap up this chapter, we're going to cover three different ways of populating DropDownList controls using ASP.NET. This example uses WebControls, but you could easily convert to using HtmlControls using the same syntax. The complete source code for the ASP page and codebehind is in Listings 5.3 and 5.4.

Listing 5.3. Populating drop-down lists (DropDownList.aspx).
 <%@ Page language="c#" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required