QA


Q&A

Q1:

Earlier in this chapter we worked on an example of filtering a GridView's data using a DropDownList. Would it have been possible to use a RadioButtonList in place of the DropDownList?

A1:

Sure, a RadioButtonList would have worked equally as well; in fact, exercise 1 asks you to build an ASP.NET page that filters the data displayed using a RadioButtonList.

When using a RadioButtonList to filter results, however, there is one point to keep in mind: by default, a RadioButtonList doesn't have a selected item. Therefore, when the page first loads the parameter used to filter, the SqlDataSource will be missing and an exception will be raised. To circumvent this problem, you'll need to add a default value to the parameter when constructing your WHERE clause parameter in the SqlDataSource control's wizard. Simply use as a default value one of the values of the Genre column, like Business, or a blank string if you don't want any results returned initially.




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