Data Binding Overview in ASPNET

One of the big goals forASP.NET 2.0 was to dramatically reduce the amount of application code programmers had to write when designing rich, interactive, data-bound Web user interfaces. To accomplish this, a bunch of new controls and components were added to the .NET Framework for ASP.NET Web forms, many of them focused on data-bound scenarios. Additionally, the designer in Visual Studio 2005 has been improved to the point that for many common scenarios, you can get exactly what you want without writing a line of programmatic code, and this is done without causing unnecessary coupling between your data sources and your bound controls.

The biggest change in terms of how you approach data binding in ASP.NET 2.0 is the use of data source controls, which are a new kind of control that are conceptually very similar to a BindingSource component in Wndows Forms 2.0. Data source controls provide a layer of decoupling between a data source and the controls to which it gets bound. However, the similarities stop at the conceptual level. The way that you define and employ data source controls in ASP.NET is quite different from the way that you usd3indingSources in Windows Forms, and will be the subject of the following sections in this appendix.

There are also a number of additions to the set of controls available for data-bound scenarios in ASP.NET pages, as well as enhancements to existing controls. The most significant new data-bound controls that I will cover are the GridView, DetailsView, Form View, and TReeView controls. Existing controls such asDropDownList, ListBox, TextBox, and Label are used in much the same way as they were in ASP.NET 1 .X, except that you should bind them to data source controls instead of directly to data sources to provide the same indirection and a consistent model with the new data controls. Additionally, the need to set up individual control bindings is greatly reduced due to the capabilities of the DetailsView and Form View controls, as you will see later in this appendix.

4 PREY

0 0

Post a comment