Exforsys.com
 
Home Tutorials VB.NET 2005
 

.NET Complex Data Binding

 

.NET Complex Data Binding - Page 2

Page 2 of 2


.


.


.



One-Way and Two-Way Data Binding

All that we have done, so far, is to ensure that the data in a database is retrieved and displayed to us using any of the Forms Controls. It is clear that some controls can take user input while others are prevented from taking user input. It is also evident that some controls provide dynamic views while others display only static views based on a snapshot of data.


This brings us to the next concept that needs to be understood. Binding allows data update depending on the type of control used. Bindings that do not allow the user to update the database that provided the user with the data are called One-Way Binding and the type of binding that allows the user to update the underlying database are called Two-Way Binding.


Two way bindings are available in all cases where the data source can be updated and the control has the capacity to display updated data. The user, however, has the option to prevent this by editing the properties of the control.


Closely allied to the concept of two way binding is the concept of System.DataSet. This concept was introduced in Visual Basic.NET to present a XML schema that is aware of the rowstate property. The rowstate property gets or sets the value of the rows so as to track changes to the row.


The System.Data.Common.DataAdapter’s Update method examines the System.Data.DataRow.RowState property, and executes the required INSERT, UPDATE, or DELETE statements iteratively for each row, based on the order of the indexes configured in the System.Data.DataSet. For example, System.Data.Common.DataAdapter.Update might execute a DELETE statement, followed by an INSERT statement, and then another DELETE statement, due to the ordering of the rows in the System.Data.DataTable. Let us see the code fragment for this


Click here for Sample Code


It should be noted that these statements are not executed as a batch process; each row is updated individually. This could raise some exceptions which the users will have to handle separately.


The BindingContext and CurrencyManager Classes

Binding controls on a form to the ADO.NET DataSet and providing navigation services that keep all controls in sync is accomplished through the use of two objects known as the CurrencyManager and the BindingContext. For each data-bound form that the user creates in the application, the user will have at least one BindingContext object. This object will be responsible for any CurrencyManager objects. The user will have one CurrencyManager object for each data source on the user’s form. The CurrencyManager object is responsible for keeping track of the user’s position in the DataSet and for the overall supervision of the bindings to the data source. The user will call the necessary methods on the CurrencyManager object to navigate through the records, and the BindingContext ensures that all bound controls are kept in sync. The DataNavigator control used in this application provides that functionality in an easier-to-use form.



The use of binding context can be illustrated by the following example where three text boxes are bound to three columns of the same table. While navigating, the synchronization of the three columns is made possible by BindingContext.





First Page: .NET Complex Data Binding


Read Next: .NET Data Form Wizard



 

 

Comments


renu said:

  how to place data from datagridview from one form and acess the same row in other form textbox's..
February 17, 2009, 2:25 pm

Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links

 

Subscribe via RSS


Get Daily Updates via Subscribe to Exforsys Free Training via email


Get Latest Free Training Updates delivered directly to your Inbox...

Enter your email address:


 

Subscribe to Exforsys Free Training via RSS
 

 
Partners -  Privacy and Legal Policy -  Site News -  Contact   Sitemap  

Copyright © 2000 - 2009 exforsys.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape