473,776 Members | 1,650 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.ActiveCon trol != null && (this.ActiveCon trol is TextBox ||
this.ActiveCont rol is ComboBox || this.ActiveCont rol is MaskedTextBox))
this.ActiveCont rol.DataBinding s[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 2405
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.ActiveCon trol != null && (this.ActiveCon trol is TextBox ||
this.ActiveCont rol is ComboBox || this.ActiveCont rol is MaskedTextBox))
this.ActiveCont rol.DataBinding s[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.SelectNext Control 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.ActiveCon trol != null && (this.ActiveCon trol is TextBox ||
this.ActiveCont rol is ComboBox || this.ActiveCont rol is MaskedTextBox))
this.ActiveCont rol.DataBinding s[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.ActiveCont rol = null;
form.ActiveCont rol = textBox1;
}
Dec 23 '05 #3

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

Similar topics

4
3649
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
1243
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 pages which use the DataBinder.Eval method, I get an error saying the referenced assembly could not be found. For example, say I have an object named ObjectName. In the code behind, I can use this fine, but the following will cause the error I...
2
4569
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
3162
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, depending on which menu item a user selects. Each of these controls follows the same basic pattern: Get a dataset from the database and then display the results using basic databinding. Everything works fine except that I'll occaisionally get an...
13
5347
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 would like to do (of course) is set the DataBindings. Something clearly is wrong with the approach I use, because I can't set the Properties in the Designer, the DataSource-Property appears like 'ReadOnly', there is no "dropdown" with the list from...
8
2185
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 answered... In 1.1 we always did our own myDataAdapter.fills and we liked that control for lots of good reasons. Now the new DataSource (or is it a TableAdapter:Dataset) automatically fills the Gridview. How can we control that fill? In a...
8
2090
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 generic type Field<T> (see sample code). public class Employee { public Field<stringForename
1
1633
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; Performance with databinding is good in asp.net 2.0 ? Would you prefer: databinding or set value to Text property of control ?
0
1898
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 is clicked the usercontrol raises an event indicating that the data in the database that relates to this user control is to be deleted.
0
9464
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10120
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8952
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7471
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6722
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5367
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4031
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3622
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2860
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.