473,668 Members | 2,491 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C#-app : Write to one dataset causes another dataset to revert to previous form

7 New Member
I have two datasets. One dataset table from dataset1 is bound to a list box. On selection in the list box dataset2 has 9 tables that are populated from the database. these tables are then data-bound to 9 combo boxes. Following selection of items in the combo boxes and the click of a button, the results are then manually written back to the first table in dataset1. The problem that I am having is that after the selection in the first combo box is written to the table, all of the combo boxes revert to their previous selection. Following are the sections of code which I think should be needed:

//create the tables in the second dataset
cbLineupPositio n[i-1].DisplayMember = "PositionNa me";
cbLineupPositio n[i-1].ValueMember = "PositionID ";
cbLineupPositio n[i-1].DataSource =DataSet2.Table s["LineupPosition "+i.ToStrin g()];


DataSet.Tables["teams"].Rows[lbTeams.Selecte dIndex]["One"]
=cbLineupName[0].SelectedValue;
DataSet.Tables["teams"].Rows[lbTeams.Selecte dIndex]["Two"] =
cbLineupName[1].SelectedValue;
DataSet.Tables["teams"].Rows[lbTeams.Selecte dIndex]["Three"] =
cbLineupName[2].SelectedValue;
DataSet.Tables["teams"].Rows[lbTeams.Selecte dIndex]["Four"] =
cbLineupName[3].SelectedValue;
DataSet.Tables["teams"].Rows[lbTeams.Selecte dIndex]["Five"] =
cbLineupName[4].SelectedValue;
DataSet.Tables["teams"].Rows[lbTeams.Selecte dIndex]["Six"] =
cbLineupName[5].SelectedValue;
DataSet.Tables["teams"].Rows[lbTeams.Selecte dIndex]["Seven"] =
cbLineupName[6].SelectedValue;
DataSet.Tables["teams"].Rows[lbTeams.Selecte dIndex]["Eight"] =
cbLineupName[7].SelectedValue;
DataSet.Tables["teams"].Rows[lbTeams.Selecte dIndex]["Nine"] =
cbLineupName[8].SelectedValue;
Jun 4 '07 #1
5 1533
Plater
7,872 Recognized Expert Expert
My guess would be that since you are writing to the dataset that populates the first listbox, it is re-binding the listbox to the newly effected dataset. And the selection_chang e event gets fired on a databind, which in turn fires off the "populate all my combo boxes" dealy.
Jun 4 '07 #2
mydogisbox
7 New Member
Thanks a lot for the quick reply. I will look at that possibility.
Jun 4 '07 #3
mydogisbox
7 New Member
On brief inspection that appears to be exactly what is happening. Thanks a lot. :-)
Jun 4 '07 #4
Plater
7,872 Recognized Expert Expert
For what it's worth, I usually don't do direct editing of my dataset's.
I'll have a like PopulateClients () function who's job it is to retrieve the dataset and populate my listbox/combobox/datagridview.
Then I will do my manipulating, and when i'm all done and want to refresh, I will call the Populate function again.

If you want to directly edit the datasets, you could try:
retrieving your dataset.
make a CLONE/COPY of it.
use one to populate listbox
use other to work with the combo boxes and changing of data with it
Then go back to stop and make a copy of the dataset with new data and populate the listbox with a copy of it and manipulate the other.
I think that should work?
Jun 4 '07 #5
mydogisbox
7 New Member
If you want to directly edit the datasets, you could try:
retrieving your dataset.
make a CLONE/COPY of it.
use one to populate listbox
use other to work with the combo boxes and changing of data with it
Then go back to stop and make a copy of the dataset with new data and populate the listbox with a copy of it and manipulate the other.
I think that should work?
I would think that would work. Is there a simple way to clone a dataset?

Added: It turns out I can be much lazier than that. I simply have a bool that indicates whether or not I'm currently saving and if so, I make the SelectedIndexCh anged event do nothing.

Thanks again for your help.
Jun 4 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1865
by: MissiMaths | last post by:
I am creating a reference table of all the information used to draw a sample. I start by first clearing the table in form1 using a delete query. Then after the user selects certain options, i create a string "optionString" and put it into my table refTab in the appropriate field. DoCmd.OpenQuery "ClearRefTable" Dim MyDB As Database
2
1645
by: Tim Stevens | last post by:
Hello, This is the first time I have had to resort to posting on here, as Ive always been able to find a solution to my problems in the past by browsing postings by others. So, to start with I thank you all for so much help in the past ... To my current problem... Ive a fairly sizable application, front end local and back end networked both on access 97. All running on NT4 worstation front ends, think the back end servers are 2000, but...
8
14114
by: Cheryl | last post by:
How can I create a button that would take me back to the previous form not the previous record, but the previous form that I just moved from using VBA? Any sample code would be greatly appreciated.
1
1665
by: abc my vclass | last post by:
Is VS2005 debugger let me to see dataset, datatable data as table form? I found if I watch some table or dataset variable is very very hard to see. Is there any good tools or add-ins for debugger to see table-form variable.
2
3829
by: rrflore2 | last post by:
Ok. I'm writing and deleting to an xml file using a dataset. I have a function in my codebehind page that binds a listbox to the dataset that performs the writes/deletes. Everything seems to be working fine except, I cannot get the listbox to update after the xml file is written to. I've tried to rebind the listbox and a bunch of other things; nothing seems to work. I'm sure this is simple fix but, I cannot seem to figure it out. I...
3
1986
by: Gilberto | last post by:
Hello This must be pretty simple but i havent found the way to do it. I have a form with a button that opens another form on click. WHAT command and WHERE do i need to CLOSE the previous form (first form) after clicking the button the opens the new one?? Ive tried docmd.close in several events but it doesnt work. Thanks, Gilberto
1
1386
by: sweatha | last post by:
Hi Friends I have designed a form with 1 DropDownList box named “ddlShow_time”& the form name is “Default4.aspx”. Just like that, I have the database(SQL SERVER 2000) as Table Name: ShowTime ----------------------------------------------------------------------------- Theater_Name ShowTime Movie_Name ------------------------------------------------------------------------------- Udhayam 10:00am ...
4
5918
by: John Sheppard | last post by:
Hello there I was wondering if anyone could help me, I am trying to pass a typed dataset to a dialoged child form by reference. I have binding sources sitting on the child form. So to refresh them I just set their datasource. I am guessing this is probably what is causing the problem. Is there a better way to do this? Anyway this all works happily and things show up when the record already exists but I have 2 problems ; 1) When I add...
5
3334
by: danon | last post by:
Hi to you all can any one tell me how to programme a button so it can take back to the previous form please many thanks
0
8893
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
8799
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...
1
8586
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8658
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...
1
6209
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
5681
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
4205
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...
2
2026
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1786
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.