Data Binding

What Does Data Binding Mean?

Data binding, in the context of .NET, is the method by which controls on a user interface (UI) of a client application are configured to fetch from, or update data into, a data source, such as a database or XML document.


Prior to .NET, access to data binding models was limited to databases. Thus, many database management systems (DBM) could indirectly access the data source through their application programming interface (API) without any flexibility in controlling the data binding process. This problem is addressed in .NET by providing fine control of how the data is bound and the behavior of UI with Windows Forms and ADO.NET classes in the framework. The development of Web applications is simplified by providing data binding capability to Web pages using .NET server side Web controls.

Techopedia Explains Data Binding

The advantages of using data binding in .NET are as follows:

  1. Reduction in code size
  2. Better performance of the application
  3. Rapid development of data-driven applications
  4. Customization of default data binding process by modifying the generated code wherever necessary
  5. Fine control on data binding through events
  6. Visual feedback on validation errors by associating validation rules of data with built-in data type validation of controls in UI (for example, date value entered in date control)

Data binding forms the link to synchronize data between the data provider (data source) and the data consumer (UI displaying data), enabling two-way connection between visual elements and the data source. For example, the text property of a Windows form text box may be bound to the name of a student fetched from a database. Binding also may be applied to a graphic of an image control, background color of a control or other property of a control on a form.

The .NET framework provides simple and complex data binding options in Windows Forms to access data from databases and structures, such as arrays and collections. In the case of a simple data binding option, one control in UI is bound to one data value in a data source while in complex option. Also, one control is bound to a collection of data, such as a Datagrid control bound to a dataset representing a list of values.

Windows Presentation Framework (WPF) in .NET 4.0 implemented the concept of data binding by connecting the properties of binding target objects (WPF elements) and any data source, including Language Integrated Query (LINQ) queries, Common Language Runtime (CLR) objects, XML and other data sources. It provides data templates for controlling presentation of data.

When data binding is applied to ASP.NET pages, any server control can be bound to simple properties, collections, expressions and methods, etc. All data binding expressions must be contained within the characters <% #%>. The framework classes, like Dataset, DataReader and others are used to obtain data from the database and link to the controls in the Web page.

The limitations of data binding include the overhead caused by checking the version of controls, the Open Database Connectivity (ODBC) driver/provider installed in the user system and the distribution of a new version of controls and middleware required to use the application in the user’s system.


Related Terms

Margaret Rouse
Technology Expert

Margaret is an award-winning technical writer and teacher known for her ability to explain complex technical subjects to a non-technical business audience. Over the past twenty years, her IT definitions have been published by Que in an encyclopedia of technology terms and cited in articles by the New York Times, Time Magazine, USA Today, ZDNet, PC Magazine, and Discovery Magazine. She joined Techopedia in 2011. Margaret's idea of a fun day is helping IT and business professionals learn to speak each other’s highly specialized languages.