Sams Teach Yourself ASP.NET 2.0 in 24 Hours, Complete Starter Kit
In this hour we looked at a hodgepodge of data-related topics, starting with an examination of the fields available for use with the data Web controls. The three fields we looked at were the CheckBoxField, HyperLinkField, and ImageField. The CheckBoxField is automatically used when binding a bit column to a GridView or DetailsView. The HyperLinkField renders a link; and the ImageField, an image. Both the HyperLinkField and ImageField have pairs of properties that allow us to associate a database field value with the properties of the fields' corresponding HyperLink or Image controls. Specifically, we saw how to add a "Buy" link to each book that, when clicked, would whisk the user to Amazon.com, as well as how to display a picture of the book's cover in each row of a GridView. We also looked at how to use WHERE clause filter expressions with wildcards. This technique is useful if you want to allow the user to search for a particular substring within a database field. This hour concluded with an examination of data binding. Although the data Web controls natively handle data binding for us most of the time, if we add a TemplateField or want to use a Web control other than the TextBox in the editing or inserting interface, we need to be able to bind the appropriate database column values to the appropriate Web control properties. We can accomplish this by clicking on the Edit DataBindings link in the smart tag of a Web control in a TemplateField. This hour wraps up our look at accessing and modifying database data through an ASP.NET web page. Working with data through a web page is a very common task, so it's important that you're comfortable with the processes examined. Before you continue, it behooves you to spend adequate time practicing creating data-driven ASP.NET pages. I strongly encourage that you work through all the exercises from Hour 13 through Hour 18 before moving onward in your studies. |
Категории