
Data Binding | 165
Data Access
and Binding
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
ASP.NET introduces a new server-side data-binding feature that addresses these
issues. Data binding to server controls in ASP.NET can significantly reduce the
amount of code that needs to be written and maintained for displaying data. In
addition, since all data binding occurs on the server side and only HTML is
returned to the client, server-side data binding provides great cross-browser
compatibility.
You can perform data binding against properties for single-value binding or
against data sources that contain multiple rows, such as collections, data tables,
and data views, allowing rich formatting of data with a minimum of code. Data
binding can be performed explicitly by using the
<%# %> syntax, or implicitly by
setting the data source of a bindable control to an appropriate object (objects to
be bound to must implement the
IEnumerable interface). In both cases, the data
binding occurs when the Databind method of the page or control is called. Note
that when Databind is called at the page level, the
Page class will, in turn, call
Databind on all of its constituent controls. Therefore, if you have a large number
of controls on a page, only a few of which are databound, it may be more efficient
to call the Databind method of these controls directly. ...