The databinding support for the .NET Framework version 1.x was the primary reason for using a DataSet. Using it made life much easier, and trying to develop non-DataSet components was correspondingly harder.
But that’s all changed in .NET 2.0. You can bind to a business object very simply. First, you need to add a DataConnector for your business object to your form (or user control). Then, the following three lines of code (this is with Windows Forms, it may be slightly different for ASP.NET 2.0):
// Business Object DataConnector
this.BusinessObjectDataConnector =
new System.Windows.Forms.DataConnector(this.components);
this.BusinessObjectDataConnector.DataSource =
Services.BusinessObject.BusinessObjectDataClass.Load();
// DataBindings
this.textbox1.DataBindings.Add(
new Binding("Text", this.BusinessObjectDataConnector,
"SomeProperty", true) );
That’s it! Now if you change the value of textbox1, it updates the BusinessObject’s SomeProperty value for you!
Posted
04-04-2005 9:08 AM
by
Darrell Norton