473,387 Members | 1,420 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,387 software developers and data experts.

Databinding is late!

The controls in my form are bounded to a datasource, including textboxes,
comboboxes, etc...
Something lame happens: In runtime, the last focused control before clicking
on my save button, doesn't have its datasource bounded value refreshed with
the new data inputed. I think the control's LostFocus event it's not properly
fired when I click a ToolStrip button, and the databinding is not updated.

I came with the following piece of code on the Save function to solve this
problem:

if (this.ActiveControl != null && (this.ActiveControl is TextBox ||
this.ActiveControl is ComboBox || this.ActiveControl is MaskedTextBox))
this.ActiveControl.DataBindings[0].WriteValue();

It works fine. I just wonder if there's a better and cleaner way to solve my
problem; a property or something.

Thanks and happy chrtistmas.
Dec 23 '05 #1
2 2391
Bruno Rodrigues wrote:
The controls in my form are bounded to a datasource, including textboxes,
comboboxes, etc...
Something lame happens: In runtime, the last focused control before clicking
on my save button, doesn't have its datasource bounded value refreshed with
the new data inputed. I think the control's LostFocus event it's not properly
fired when I click a ToolStrip button, and the databinding is not updated.

I came with the following piece of code on the Save function to solve this
problem:

if (this.ActiveControl != null && (this.ActiveControl is TextBox ||
this.ActiveControl is ComboBox || this.ActiveControl is MaskedTextBox))
this.ActiveControl.DataBindings[0].WriteValue();

It works fine. I just wonder if there's a better and cleaner way to solve my
problem; a property or something.

Thanks and happy chrtistmas.


We had the same problem with our application... Our solution was to call
Form.SelectNextControl as it applies a value when leaves the control

I know, not a clean one but i didn't find anything better. Unfortunately
..NET's binding mechanism sucks badly :(

MuZZy
Dec 23 '05 #2
Bruno Rodrigues wrote:
The controls in my form are bounded to a datasource, including textboxes,
comboboxes, etc...
Something lame happens: In runtime, the last focused control before clicking
on my save button, doesn't have its datasource bounded value refreshed with
the new data inputed. I think the control's LostFocus event it's not properly
fired when I click a ToolStrip button, and the databinding is not updated.

I came with the following piece of code on the Save function to solve this
problem:

if (this.ActiveControl != null && (this.ActiveControl is TextBox ||
this.ActiveControl is ComboBox || this.ActiveControl is MaskedTextBox))
this.ActiveControl.DataBindings[0].WriteValue();

It works fine. I just wonder if there's a better and cleaner way to solve my
problem; a property or something.

Thanks and happy chrtistmas.


By the way, in my app i came across another stupid issue with bindings -
if you have a bound text box and it's active control on the form, and
you activate another form, then go back to the first form and type
something in that active text box, it looses binding, i.e. whaterver you
type in it will no longer go to the dataset.

The workaround i found was to reactivate the text control when form
becomes active again:

void form_Activate(...)
{
form.ActiveControl = null;
form.ActiveControl = textBox1;
}
Dec 23 '05 #3

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

Similar topics

4
by: CGuy | last post by:
Hi, I have an ASPX page which has a datagrid and this datagrid is bound to a Custom Collection. sample code this.DataGrid1.DataSource = UserManager.Users; this.DataGrid1.DataBind();
2
by: Steven | last post by:
Hi, I'm having an odd problem with late databinding (using DataBinder.Eval). I have my Business Logic and Facade assemblies in the GAC, and just about everything works fine, however, when using...
2
by: z. f. | last post by:
Hi, can i call databind on my repeater in my Page.PreRender event? is there some problems with it that i should consider? TIA, z.
3
by: Kevin Swanson | last post by:
I'm writing what should be a very simple app against an Oracle database. The app has a number of user controls, any one of which is loaded into a main display page using the loadControl method,...
13
by: Michael Maes | last post by:
Hi, I have a UserControl containing some controls of which one is a ComboBox. All the InternalControls are Private and some are allowed to be accessed through Public Methods. One of the things I...
8
by: GaryDean | last post by:
We have been noticing that questions on vs.2005/2.0 don't appear to get much in answers so I'm reposting some questions posted by some of the programmers here in our organization that never got...
8
by: Dirk | last post by:
Hello, I have a problem to use databinding with my business layer classes. My data class does not have simple properties (string, int or datetime), instead, all my properties are objects of the...
1
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?= | last post by:
Hello to all, I want to know if DataBinding in asp.net 2,0 is better than to fill up the values of the controls of the following form: this.miControlTextBox.Text = valorParaControlTextbox; ...
0
by: Dave A | last post by:
I have a user control that is dynamically loaded into a repeater; (so the user control appears several times) The user control features a text box and a delete button. When the delete button...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.