Introduction To Data Binding in ASP.NET
Data Binding is a way of connecting the web application to the database of the business. This is not the same as displaying the data in the web application UI. The data changes are dynamic in nature (in most cases) and UI shall reflect the same changes as the database. So Data Binding provides this connection which makes this possible. The concept of data binding in ASP.NET can be implemented easily. Data Binding in ASP.NET offers a convenient, efficient and simple way to establish linkage between the application data and the server control.
What Is Data Binding?
Data Binding is a way to provide a linkage or connection between the application and the database.
Let’s see some terminologies:
- Binding Source: Holds business data, it can be perceived as a variable that holds application data.
- Binding Target: It is the UI element or the server control to which data will be bounded.
- Dependency Object: It is associated with the Binding Target.
- Dependency Property: It is the attribute or the property of the dependency object to which the data will be bounded.
- Source Object: It is associated with Binding Source and is associated with the business data.
- Source Property: It is the attribute or the property of the source object whose value will be representing the actual data.
Data Binding direction plays an important role in the propagation of data to and from between the Binding Source and Binding Target. In the case of one-way Binding, the changes made in business data will be reflected in the user interface but not the other way around. This is generally applied to the scenarios where data has to be read-only, and the use of user interface is for information purpose only, or in scenarios where the calculation on data are performed based on the user inputs.
On the other hand, if there’s two-way binding then changes made in data on either side would be reflected for both source and target as well, both objects are synchronized automatically. This is helpful in the interactive user interfaces where changes need to be updated instantly.
How To Perform Data Binding In ASP.NET?
In ASP.NET a user can perform data binding with the form controls.
Majorly two types of Data Binding can be performed in ASP.NET.
- Simple Data Binding
- Declarative Data Binding
1. Simple Data Binding: In simple data, we have a read-only section list and controls are bound to a dataset. The controls can be bound to an array or a list of fields(Column) from a database. Section list pulls two values from the data source or the database. Out of two values, one value will be displayed by the list and the second value will be considered as the corresponding value to display.
2. Declarative Data Binding: The process of data binding a component in the form of a Data Grid or record list or a list box is declarative data binding process. Declarative Data Binding is used when there are more than one element exists in the database.
Advantages Of Data Binding
There are several advantages of Data Binding some of them are displayed below:
- Applications based on data can be developed efficiently and easily.
- Size of code reduces by multifold without affecting the desired outputs.
- It improves the quality of the application.
- You can use events to have control over the Data Binding process.
- You can modify the code easily, it’s quite flexible.
- Developers enjoy the benefit of having the option for both abound and unbound approach for building any web application.
Conclusion
Data Binding is a way of connecting the web application to the database of the business. In this article, we have seen what it exactly means, how this can be done, and the advantages of the same.
Recommended Articles
This is a guide to Data Binding in ASP.NET. Here we discuss the introduction, what is data binding with its types along with advantages respectively. You can also go through our other suggested articles to learn more –
Are you preparing for the entrance exam ?
Join our Programming Languages test series to get more practice in your preparation
View More