Thursday 5 April 2012

Hierarchical Data Binding in .Net

.net provides the programmers with server-side controls to bind the data. In other words, it is used to display the client with the format the control is designed for. Many data binding examples are two dimensional i.e. binding of simple flat data source with the result of queries made to the database. But sometimes there are several occasion when data doesn’t fit into a two dimensional spaces that’s where it fails. Data binding are of three types: Hierarchical data binding, Hierarchical Database data binding and binding with XML data.

The only required condition to bind the data to the server-side control is the control must support the property called DataSource including the method called DataBind(). The data source to which the control is to be attached must implement IEnumerable interface with the exception of DataSet and DataTable which can be bound directly. For nested Hierarchical data binding, developers are required to bind the data on the sub-items of each one of them. In other word, the needed condition for programmers is that another data bound control with the ItemTemplate of the Repeater (this server-side control is needed for the purpose of hierarchical data binding which gives the ItemTemplate that shows the each given item in the enumerable data source).
The tough part is to map the SubItems collection of the Item currently attached to the DataSource property of the nested Repeater. There is also a coding type of declaration in the DataSource property of the nested Repeater to achieve hierarchical data binding. The nested data bind will occur only once per Item in the top level. It is important to note that when the pair of nested data bound control, the expressions are scoped to the closest control. To bind the data from the database is to able defining the relationship within the DataSet for extracting the data hierarchically. For XML hierarchical data binding the provided XML API is used for simplifying the coding. For satisfying all the data bonded controls hierarchical data binding must be used.

Hierarchical data binding is very important in desktop applications and it brings flexibility to all the programs. Hierarchical data binding is used in many other frameworks but in .NET it is very easy to implement.

No comments:

Post a Comment