Chapter 9: Data Controls
Overview
It's often remarked that a large percentage of Windows applications are little more than attractive window dressings over a relational database. This is especially true of the internal software that powers most businesses. The chief responsibility of this type of software is to allow highly structured data entry and provide reportgenerating modules that summarize vast quantities of information. As a result, a great deal of thought (and code) is usually concentrated in the user interface tier.
Of course, databases aren't only used for workflow and administrative software. Almost every application needs to connect to a data source and retrieve, format, and display information at some point. Even an Internet e-commerce site is really just an interactive product catalog that draws information from one table and logs transactions in another. The situation becomes more complicated with Windows applications, which provide a wide range of user interface options for displaying data.
This chapter considers how you can use Windows controls with data. I'll also share some advice about how to do it without hopelessly intermingling details about your data source in your user interface code. You'll consider three fundamental topics:
How to use .NET's data-binding framework with any generic control. You'll also learn about the specialized DataGrid control.
How to create "data aware" controls-controls that interact efficiently and intelligently with data sources without requiring data binding.
How to use adapter classes and miscellaneous wizardry to help automate the shuffle of information through the levels of your application, and write more focused code.