Summary


In the preceding hour we saw how to retrieve data from a database in an ASP.NET page through the SqlDataSource control. In this hour, we saw how to take that data and display it in the page using a data Web control. All data Web controls essentially work the same: They are added to the page and assigned a data source control. When a user visits the ASP.NET page, the data source control grabs the data from the database, and the data Web control renders its content based on the data in its data source control. There are five data Web controls, with the two most commonly used ones being the GridView and DetailsView.

The GridView displays all of the records in its corresponding data source control in an HTML <table>. Each record in the data source control is rendered as a table row, with each column in each row being rendered as a table cell. The DetailsView, on the other hand, displays only one record at a time from the data source control. This record is also displayed in a <table>, but unlike the GridView, the DetailsView renders a table row for each of the columns in its data source control, with each row having two columns containing the name and value of the corresponding database table column.

Both the GridView and DetailsView make it very easy to customize the appearance at a number of levels. The numerous control-level and row-level properties can be accessed through the Properties window, while field-level changes can be made through the Fields dialog box, which is accessible through the smart tag. Best of all, both controls sport an Auto Format dialog box for artistically challenged individuals like myself.

This hour focused on displaying data. In the next hour we'll see how to use the data source controls and the data Web controls in tandem to edit, update, insert, and delete data.




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