Summary

Chapter 5 - Reading Data using the Dataset Object
byJohn Kauffman, Fabio Claudio Ferracchiatiet al.?
Wrox Press ?2002

This chapter has addressed a variety of real-world questions that ASP.NET pages are asked to deal with. We started by discussing the differences between the DataReader and DataSet, noting that the DataSet holds data in memory, and allows manipulation of this data without any further connection to the data source being maintained. We also saw that the DataSet is not concerned with the origin of the data, and throughout the chapter we worked comfortably with different sets of data from different sources.

A DataSet object contains DataTable objects, rather like the tables in an ordinary database, and these in turn contain DataColumn and DataRow objects. It is important to keep in mind the relationship between these objects, and the syntax necessary to refer to them. We saw how the data adapter uses a connection object and either an SQL string or a command object to fill a DataTable with data, and the ReadXml() method to fill a DataTable with data from an XML file.

We looked at how to bind a DataSet to a DataGrid for easy display, and then went deeper into the DataSet, looking at how to extract values from particular columns. We saw the importance of field data types when we looked at creating relationships between DataTable objects with the DataRelation object, and had a brief look at how an XML schema can provide this information for XML data.

ADO.NET enables us to create a DataView object, which provides us with a specific way to look at data within a DataTable. With a DataView, we can allow visitors to our site to sort and filter the data that is displayed in front of them, enabling a more customized view of our data.

We don't have to accept the default DataGrid that shows every DataColumn of a DataTable. Instead, we can describe the DataGrid as a set of BoundColumns, where we define for each column the field from which they take their data, the visibility (controllable at runtime), the heading, and other characteristics. Likewise, we don't have to show all of the rows in a DataGrid. With ASP.NET, it's easy to present only a set of rows at a time, with handy hyperlinks for paging through the data.

Last of all, we looked at how to link an ASP.NET Calendar control to a data source, and provided a more polished example of filtering our data, with options from a data source bound to a drop-down list.



Beginning ASP. NET 2.0 and Databases
Beginning ASP.NET 2.0 and Databases (Wrox Beginning Guides)
ISBN: 0471781347
EAN: 2147483647
Year: 2004
Pages: 263

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