Chapter 10: Viewing .NET Data

 
Chapter 10 - Viewing .NET Data
bySimon Robinsonet al.
Wrox Press 2002
  

Overview

The last chapter was devoted to various ways of selecting and changing data. This chapter will carry on from where that one left off, and will demonstrate how you can display data to the user by binding to various Windows controls.

The data binding capabilities of .NET are similar to ADO and the Visual Basic controls. All .NET languages are now capable of using the same controls and methods , which can make life a good deal easier. The most revolutionary aspect of the .NET data access model is the new DataGrid control. We'll spend the first part of this chapter describing its features.

One of the best features of the new DataGrid control is its flexibility the data source can be an Array , DataTable , DataView , DataSet , or a component that implements either the IListSource or IList interface. With the large number of options available we'll spend some time early on in the chapter showing how each of these sources of data can be used and viewed within the DataGrid .

Data binding is a common requirement, and although VB 6 (and to a certain extent MFC) had data binding capabilities, under .NET, all managed languages gain the ability to link to data. What's more, once bound to a column of data, a control will be updated automatically when the current "row" of data changes. In this chapter we will explore some of the capabilities of data binding, and show how to connect data to Windows Forms controls. We'll also see some of the inner workings of data binding to get a better understanding of how it works.

Data sources have become much more integrated into Visual Studio .NET, and in this chapter we'll show how to use the Server Explorer to create a connection and generate a DataSet , all without writing a line of code. We'll also cover the use of the XSD schema editor within Visual Studio .NET, giving an example of the code generated by the editor.

The chapter concludes with an example of how to utilize hit testing and reflection on rows in the DataGrid . This example brings together some aspects discussed elsewhere in the book, such as responding to events, reflection, custom attributes, and there's some data access thrown in too!

  


Professional C#. 2nd Edition
Performance Consulting: A Practical Guide for HR and Learning Professionals
ISBN: 1576754359
EAN: 2147483647
Year: 2002
Pages: 244

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