473,320 Members | 1,719 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

When does DataBinding update? How to force an update?

I'm wondering about the mechanics of databinding.

Say that a textbox is bound to a property of a business object. The
business object is a "Person". The control is a textbox called
"ctlFirstName", and it's bound to the "FirstName" property of "Person".

Why doesn't the following work?

myForm.Show();
Person p = new Person();
p.FirstName = "Jack";
// ctlFirstName is TextBox on my form
ctlFirstName.DataBindings.Add("Text", person, "FirstName");
Assert.AreEqual(form.textBox.Text, person.FirstName); // Works!
ctlFirstName.Text = "Bill";
Assert.AreEqual(ctrlFirstName.Text, person.FirstName); // Fails
// Expected control & datasource to both be "Bill"
// But control is Bill & datasource is still "Jack"
When you type text inside a bound textbox and then tab out of the
control, the datasource is automatically updated with the new data. What
exactly triggers the exchange of data between a control and its
datasource? It seems to happen after the Validated event.

Is there a way to force the exchange to happen? How can you
programmatically force a bound textbox to update its datasource?

-Patrick
Nov 16 '05 #1
0 5406

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Just_Buy | last post by:
Environment: MS Access 97 Problem: Trying to force a record to update using the recordset.Update property. What syntax do I need to force a record to be updated? I have searched the...
2
by: louise raisbeck | last post by:
Hi, There seem to be several ways to update rows in sql. What is the best practice? I have written a medium sized update statement into a stored procedure, taking values from the web text...
3
by: AH | last post by:
Hi all, I noticed this strange behavior; I created a new control (example inherits from textbox) and add a new property, then I bind this new property to a field in my dataTable in a dataSet....
9
by: Dennis | last post by:
I have tried using Databinding for my application but always seem to find it very restrictive (maybe I don't completely understand it enough). I always seem to find it much easier to display a...
13
by: Michael.Suarez | last post by:
Let's suppose I have an instance of MyClass, which has the properties MyText1 and MyText2, and sets the values of MyText1 and MyText2 to 'A' and 'B' in it's constructor. Let's also suppose I...
6
by: JohnR | last post by:
I'm running into a 'timing' or 'race' condition on my form. All textbox controls are bound to a datasource, but certain other controls (like labels) need to be updated when you move to a...
3
by: SteveT | last post by:
I am trying to populate a TreeView with XML data within a DataSet. I don't see the property DataSource in the treeview, only a DataBinding. Can that property to be used to populate my TreeView or...
5
by: =?Utf-8?B?QWRhciBXZXNsZXk=?= | last post by:
Hi All, I have a GridView inside the EditItemTemplate of a FormView. Both FormView and GridView are data bound using an ObjectDataSource. When the FormView's ObjectDataSource object has a...
10
by: blaine | last post by:
Hey everyone! I'm not very good with Tk, and I am using a very simple canvas to draw some pictures (this relates to that nokia screen emulator I had a post about a few days ago). Anyway, all is...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.