473,686 Members | 2,880 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Uninitialized data-binding

Hello
I've created a form with 2 listboxes. Both have data-binding. First one
is "normal", 1:1 view of table. Second is filled using parameter from
the first one.

this.xxxTableAd apter.Fill(this .mainDataSet.XX X,
(int)this.Bindi ngContext[yyyBindingSourc e, "id"].Current);

When I do it in Form_Load() it shows first listbox with element with
"id" of value 2 selected, but this.BindingCon text[yyyBindingSourc e,
"id"].Current == 1. When I do the same thing in
yyyBindingSourc e_CurrentChange d later it gives expected results.
How can I fix the behaviour just after window creation? I guess it's
connected with listbox not initialized properly with new data between
those two .Fill() calls.

Feb 4 '06 #1
2 1770
Message passed unnoticed. So once more:
After some tests i found out that in function
setsBindingSour ce_CurrentChang ed() value:
(DataRowView)se tsBindingSource .Current)["id"]
is correct, but
BindingContext[setsBindingSour ce, "id"].Current
shows the previous value, not the new one. Is that normal? Is there any
other/better way to get that "id"?

Feb 5 '06 #2
Hi,

"Viraptor" <vi******@gmail .com> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
Message passed unnoticed. So once more:
After some tests i found out that in function
setsBindingSour ce_CurrentChang ed() value:
(DataRowView)se tsBindingSource .Current)["id"]
is correct, but
That's the correct way. A BindingSource owns a CurrencyManager which manages
a list binding and current position.

Calling:
setsBindingSour ce.Current

results in:
setsBindingSour ce.CurrencyMana ger.Current.
BindingContext[setsBindingSour ce, "id"].Current
shows the previous value, not the new one. Is that normal?
This is very confusing. In NET1.1 there were no BindingSource's , there was
a CurrencyManager and BindingContext. BindingContext used to own
CurrencyManager s.

But in NET2.0 a BindingSource directly owns a single CurrencyManager , so if
you pass a BindingSource to the indexer of any BindingContext to request a
CurrencyManager it will relay the request back to the BindingSource passed
in:

If you pass setBindingsSour ce to the indexer of *any* BindingContext:
BindingContext[setBindingsSour ce , "id"]

it will return:
setBindingsSour ce.GetRelatedCu rrencyManager(" id")

if DataMember is empty then it will return:
setBindingSourc e.CurrencyManag er

but since DataMember isn't empty it willl create a new BindingSource:
newBindingSourc e.DataSource = setBindingsSour ce
newBindingSourc e.DataMember = "id"
return newBindingSourc e.CurrencyManag er

This new BindingSource/CurrencyManager is linked with the original. When
the original changes this new one will change, usually this is used for
master-child scenarios where a field can return a child list. But since id
returns a simple integer it simply uses that as current.

So in the end you are creating an additional BindingSource/CurrencyManager
for nothing though this additional BindingSource/CurrencyManager is synced
with the original one.

Is there any
other/better way to get that "id"?


The first way you showed is good:
((DataRowView)s etsBindingSourc e.Current)["id"]

Or a more generic way:
setBindingSourc e.GetItemProper ties(null).Find ("id",false).Ge tValue(setBindi ngSource.Curren t)

HTH,
Greetings


Feb 6 '06 #3

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

Similar topics

1
14144
by: G Kannan | last post by:
Hey all! I have written a perl script to retrieve information from a HTML Form and insert the data into an Oracle database table. I am gettting the the following error message: "Use of uninitialized value in concatenation (.) at register.pl line 38, <STDIN> line 10." The PERL code is as follows:
1
15531
by: rk | last post by:
Hi, I'm a beginner for perl/cgi programs and i tried to write a cgi script and when i ran it, i got the following error. But when i verified it from the book i typed exactly whatever it is there and i checked other examples too. I did't get any clue.Can someone please help me on this. #!/usr/bin/perl use warnings;
2
5618
by: Liang | last post by:
Hi, I use "defined $r_libs->{$name}" to check first if a key exists in a hash table. But Perl gives a warning WHENEVER the key exists: "Use of uninitialized value". Would u please help to check the script, and let me know the reason? Thanks in advance. Liang
13
20290
by: rswanster | last post by:
When I compile and run the following: #include <iostream> int main() { bool f; std::cout << f << std::endl; f = not(f); std::cout << f << std::endl; }
12
2573
by: jyu.james | last post by:
I'm trying to detect reads of uninitialized global variables (that are declared in one file, and used in another as an extern). I know that ANSI C initializes all global variables to 0, however, I do not want to rely on this for initialization. Instead, I want to explicity initialize all variables myself. I've looked at tools like Compuware BoundsChecker, which does an amazing job in detecting uninitialized variables, but doesn't...
3
9572
by: julien | last post by:
Hello, Is it possible if a boolean was initialized or not? For other types of variable, I usually check if it is null. But this not possible for a boolean. Thank you Julien
21
2263
by: sanjaymeher | last post by:
Hi, Right now addDynamicMemory(char **ptr, int size) method can able to handle if input ptr is intitialized to NULL or something. But how to improve this method to handle uninitialized pointed even. Any Answer ?? Thanks, Sanjay
148
5511
by: onkar | last post by:
Given the following code & variable i . int main(int argc,char **argv){ int i; printf("%d\n",i); return 0; } here i is allocated from bss or stack ?
1
3031
by: pillbug | last post by:
Hello, I would like to know what the standard says regarding writing beyond the end of file. For example, in the following program, is the result always the same or is it system dependent? #include <cstdio> int main (int argc, char** argv) { char ch = 'A'; FILE* fh = NULL;
2
7011
by: pnsreee | last post by:
Hi All, I have the following code. The array @sub_data will contain integers or a string"NO". I have to validate if the array contain integer. If it contain "NO" then no need to validate. for ($i=1;$i<10;$i++) { Tie::CheckVariables->on_error(sub{print "ERROR!"}); tie my $data,'Tie::CheckVariables','integer';
0
8513
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
9049
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8931
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
8777
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7596
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
6437
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
5795
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
4526
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2943
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

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.