Data Binding

 <  Day Day Up  >  

In FoxPro, when you change a field's value on a screen and the corresponding data field in the underlying table is changed, you're taking a lot for granted. What's happening is called data binding .

Visual Basic .NET doesn't have data binding to the data store. Not really. What Visual Basic .NET does have is binding to the dataset, the XML string that holds the data you got from your data source. Assume you've built a form with a text box on it and then returned a typed dataset. (See Chapter 4, "A Visual Basic .NET Framework," for more information on the Customers table containing Phone fields.) Select the text box on the form, press F4 to open the Properties window, and click on the plus sign beside the Databindings property to open the two fields under the heading. Select Text, and then select Customers.Phone from the list of available dataset classes that automatically appears.

This will cause the dataset's Phone value to be copied to the text box's Text property when you get values for the rows in the dataset, and conversely it will move any value that's typed into the text box into the dataset's Phone column. That's what Visual Basic .NET calls data binding.

The dataset's AcceptChanges and RejectChanges methods correspond to FoxPro's TableUpdate() and TableRevert() functions , respectively. But that still doesn't get your data back to the data store. Think of the dataset as a cursor into which you've copied a record. You've saved the changes to the cursor, but you haven't copied the changed record back to wherever it came from. How you do that will have to wait until Chapter 4.

 <  Day Day Up  >  


Visual Fox Pro to Visual Basic.NET
Visual FoxPro to Visual Basic .NET
ISBN: 0672326493
EAN: 2147483647
Year: 2004
Pages: 130
Authors: Les Pinter

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net