Skip to Main Content
Programming ASP.NET 3.5, 4th Edition
book

Programming ASP.NET 3.5, 4th Edition

by Dan Maharry, Dan Hurwitz, Jesse Liberty
October 2008
Intermediate to advanced content levelIntermediate to advanced
1166 pages
28h 31m
English
O'Reilly Media, Inc.
Content preview from Programming ASP.NET 3.5, 4th Edition

Lists of Data

Let’s start with the most straightforward controls to which to bind data—read-only selection lists. As you saw in Chapter 4, there are several different server controls we can use to create a list of items to choose from based on data you provide to them:

  • CheckBoxList

  • DropDownList

  • RadioButtonlist

  • BulletedList

  • ReorderList

Indeed, you already saw how to bind data from an array to these lists in Chapter 4. Binding data from a DataSource control is just as straightforward.

Tip

All the properties highlighted in this section on lists are available for all five list controls, not just for the DropDownList control used in the following examples.

Binding Data to a List

Open VS2008 and create a new website for this chapter, called C8_DataAccess. Delete Default.aspx and add a new web form to the site, called SelectionList.aspx. In Design view, drag a SqlDataSource onto the page and rename it dsCustomers. Choose Configure Data Source from its smart tag and, as you did in Chapter 7, use the wizard to set the DataSource so that it connects to the AdventureWorksLT database. However, when asked how to retrieve the data from the database, choose “Specify a custom SQL statement or stored procedure” and click Next.

Selection lists need only two values from a database—one to display and one to use as the value corresponding to the display—so use the following statement and click Next. You’ll use the full name of the customer to display in the list, and the CustomerID will be the value to carry forward. ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming Microsoft® ASP.NET 3.5

Programming Microsoft® ASP.NET 3.5

Dino Esposito
Learning ASP.NET 3.5, 2nd Edition

Learning ASP.NET 3.5, 2nd Edition

Brian MacDonald, Dan Hurwitz, Jesse Liberty
Pro ASP.Net 4 in C# 2010

Pro ASP.Net 4 in C# 2010

Matthew MacDonald, Adam Freeman, Mario Szpuszta
Programming .NET 3.5

Programming .NET 3.5

Jesse Liberty, Alex Horovitz

Publisher Resources

ISBN: 9780596156657Supplemental ContentErrata Page