Hour 17. Working with Data-Bound DropDownLists, RadioButtons, and CheckBoxes


In this hour, we will cover

  • Populating the items of a drop-down list with the results from a database query

  • Creating check boxes and radio buttons based on the results of a database query

  • Using the DropDownList control to filter the contents displayed in a GridView

  • The benefits of using database information versus hard-coding drop-down list, check box, and radio button values

As we've seen over the past three hours, the data source controls enable us to easily work with database data. We simply specify what table and columns we want to work with and whether we need corresponding INSERT, UPDATE, and DELETE statements. When a data source control has been properly configured, one of a number of data Web controls can be used to allow the end user to interact with that data through an ASP.NET page. In addition to the GridView, DetailsView, FormView, Repeater, and DataList controls, ASP.NET includes a number of list controls that can also be bound to data source controls: the DropDownList, CheckBoxList, and RadioButtonList controls.

In Hour 11, "Collecting Input Using Drop-Down Lists, Radio Buttons, and Check Boxes," we looked at using the DropDownList, RadioButton, and CheckBox controls in an ASP.NET page, but we had to explicitly provide the values for the drop-down list items, radio buttons, and check boxes. That is, if we wanted a drop-down list from which users could choose their favorite ice cream flavor, we had to manually add the available flavors to the drop-down list. Now that we know how to work with databases, we can re-examine these controls from Hour 11.




Sams Teach Yourself ASP. NET 2.0 in 24 Hours, Complete Starter Kit
Sams Teach Yourself ASP.NET 2.0 in 24 Hours, Complete Starter Kit
ISBN: 0672327384
EAN: 2147483647
Year: 2004
Pages: 233

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net