This chapter focuses on binding controls to data sources in both Web Forms and Windows Forms.
Web Forms are an ASP.NETa web application platformfeature used to create user interfaces for web applications. You can use the ASP.NET page framework to create browser- and client device-independent Web Forms that run on a web server and are used to dynamically create web pages. In addition to traditional HTML elements, Web Forms pages acts as a container for server-side controls that implement rich web user interface (UI) functionality in reusable controls.
Windows Forms is the .NET platform for Windows application development providing classes that enable rich user interfaces to be constructed . Windows forms act as a container for reusable controls that implement rich functionality.
Windows and Web Form controls allow data to be displayed by binding to data sources. Data-binding is typically used for such purposes as displaying lookup or master-detail data, reporting, and data entry. There are two types of data binding: simple and complex. Simple data binding binds a control to a single data element such as the value of a field in a row of a result set. Simple binding is used by controls such as the TextBox and Label . Complex data binding binds the control to more than one data elementtypically one or more columns from multiple rows in a result set. Controls capable of complex binding include ListBox , DataList , and DataGrid controls.
Although conceptually similar, the differences between Web Forms and Windows Forms architecture results in differences in data-binding data sources to controls between the platforms. Recipe 7.1 through Recipe 7.7 show solutions for binding data to Web Forms controls, which includes solutions for simple data binding, complex data binding with updating, binding master-detail data, and data-binding images. Recipe 7.8 through Recipe 7.13 show solutions for binding data to Windows Forms controls, which includes solutions for simple data binding, complex data binding, binding master-detail data, and data-binding images from SQL Server and Microsoft Access databases. Recipe 7.16 shows how to create a Crystal Report on a Windows Form at runtime.
Recipe 7.14 shows how to use a DataView bound to a DataGrid to control editing, deleting, and inserting data. Recipe 7.15 uses a DataView bound to a DataGrid to add search capabilities to the DataGrid .
Finally, Recipe 7.17 shows how to use ADO.NET design-time features in classes without a user interface.
Connecting to Data
Retrieving and Managing Data
Searching and Analyzing Data
Adding and Modifying Data
Copying and Transferring Data
Maintaining Database Integrity
Binding Data to .NET User Interfaces
Working with XML
Optimizing .NET Data Access
Enumerating and Maintaining Database Objects
Appendix A. Converting from C# to VB Syntax