Workshop


Quiz

1.

What HyperLinkField properties would you set to what values if you wanted to display a hyperlink with the text "Buy Title" that whisked the user to the URL http://www.buybooks.com/Buy.aspx?ISBN=ISBN, where Title was the title of the book and ISBN is the ISBN.

2.

If you set the DataNavigateUrlFields property to multiple column nameslike BookID,ISBNwhat would you set the DataNavigateUrlFormatString property to in order to have a URL generated with the form http://www.books.com/Details.aspx?BookID=BookID&ISBN=ISBN?

3.

True or False: The LIKE operator in the WHERE clause can be used with columns of any data type.

4.

What are the seven types of fields that can be added to GridView or DetailsView controls?

5.

How do one-way and two-way data binding differ?

Answers

1.

To configure the URL portion of the hyperlink, you would set the DataNavigateUrlFields property to ISBN and the DataNavigateUrlFormatString property to http://www.buybooks.com/Buy.aspx?ISBN={0}. To configure the text portion, you would set the DataTextField property to Title and the DataTextFormatString property to Buy {0}.

2.

You would use {0} to inject the value of the first database column (BookID) and {1} to inject the value of the second (ISBN). Therefore, you would use http://www.books.com/Details.aspx?BookID={0}&ISBN={1}

3.

False. The LIKE operator must be used with string or date/time column types.

4.

The seven fields are: BoundField, CheckBoxField, HyperLinkField, ImageField, ButtonField, CommandField, and TemplateField.

5.

One-way data binding simply takes a specified database column's value and binds it to a specified Web control property. Two-way data binding can not only assign a database column's value to a Web control property, but can also do the inverse: It can take the value of a property and assign it to the value of a data source control parameter.

Exercises

  1. In this hour we looked at one example that used a HyperLinkField to display a "Buy" link and another that displayed the book's cover image. Create a new page that displays all of the books from the Books table in a GridView and has both a "Buy" HyperLinkField and an ImageField showing the book's cover. Also change the HyperLinkField's text to "Buy Title", where Title is the title of the book, and center the book cover image. (Hint: To center the book cover image, use the ItemStyle property of the ImageField.)

  2. In this hour we added a Recommended field to the Books table. Because users might be interested in seeing only books that are recommended, create a page that has a DropDownList with two optionsRecommended and Not Recommendedwith values of 1 and 0, respectively. Next, add a SqlDataSource control that has a WHERE clause filter expression on the Recommended field based on the value of the DropDownList. Finally, add a GridView to the page, bind it to the SqlDataSource, and test the page in a browser.

  3. In the "Specifying the Data Bindings for a Web Control" section this hour, we created an editable GridView that used a DropDownList for the Genre field's editing interface. Re-create this page, but this time use a RadioButtonList in place of the DropDownList.




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