Chapter 24. Viewing .NET Data

This chapter builds on the content of Chapter 19, "Data Access with .NET," which covers various ways of selecting and changing data, showing you how to present data to the user by binding to various Windows controls. More specifically, this chapter discusses:

  • Displaying data using the DataGridView control—new with Visual Studio 2005

  • The .NET data-binding capabilities and how they work

  • How to use the Server Explorer to create a connection and generate a DataSet class (all without writing a line of code)

  • How to use hit testing and reflection on rows in the DataGrid

You can download the source code for the examples in this chapter from the Wrox Web site at

The DataGridView Control

The DataGrid control that has been available from the initial release of .NET was functional, but had many areas that made it unsuitable for use in a commercial application—such as an inability to display images, drop-down controls, or lock columns, to name but a few. The control always felt half completed, so many control vendors provided custom grid controls that overcame these deficiencies and also provided much more functionality.

With .NET 2.0, you now have an additional Grid control—the DataGridView. This addresses many of the deficiencies of the original control, and adds significant functionality that has to this point only been available with add-on products.

The new control has similar binding capabilities as the old DataGrid, so it can bind to an Array, DataTable, ...

Get Professional C# 2005 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.