DekGenius.com
[ Team LiB ] Previous Section Next Section

Chapter 10. Data Binding

Windows Forms lets us create rich user interfaces for viewing and editing information. But these applications are often just frontends to a larger system—the information they present typically resides elsewhere. You would not want to entrust your mission-critical data to the Text property of a TextBox control, and so a great many Windows Forms applications don't own the information they present—the master copy of the data will typically be inside a database. Even applications that do not warrant the use of a full-blown database will usually still maintain a distinction between their internal representation of the data and the presentation of that data.

To help us build applications that have cleanly separated data and presentation layers, the .NET Framework provides a facility called data binding. This is a remarkably flexible architecture for managing the connection between information sources and user interface elements. It provides full support for .NET's data-access architecture, ADO.NET, but it is also extensible—it is simple to write your own data sources, and any control, including any user controls or custom controls that you write, can participate in the presentation of data.

In this chapter, we will start by examining simple data binding, which allows any source of information to be connected to any property of a control. We will then look at complex binding, which is the specialized support for more complex data sources offered by certain controls. We will then look at some of the classes in ADO.NET that are designed to be used for data binding. Finally, we will look at the DataGrid control, which makes it easy to present large amounts of structured data to the user.

    [ Team LiB ] Previous Section Next Section