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

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

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
cbLineupPosition[i-1].DisplayMember = "PositionName";
cbLineupPosition[i-1].ValueMember = "PositionID";
cbLineupPosition[i-1].DataSource =DataSet2.Tables["LineupPosition"+i.ToString()];


DataSet.Tables["teams"].Rows[lbTeams.SelectedIndex]["One"]
=cbLineupName[0].SelectedValue;
DataSet.Tables["teams"].Rows[lbTeams.SelectedIndex]["Two"] =
cbLineupName[1].SelectedValue;
DataSet.Tables["teams"].Rows[lbTeams.SelectedIndex]["Three"] =
cbLineupName[2].SelectedValue;
DataSet.Tables["teams"].Rows[lbTeams.SelectedIndex]["Four"] =
cbLineupName[3].SelectedValue;
DataSet.Tables["teams"].Rows[lbTeams.SelectedIndex]["Five"] =
cbLineupName[4].SelectedValue;
DataSet.Tables["teams"].Rows[lbTeams.SelectedIndex]["Six"] =
cbLineupName[5].SelectedValue;
DataSet.Tables["teams"].Rows[lbTeams.SelectedIndex]["Seven"] =
cbLineupName[6].SelectedValue;
DataSet.Tables["teams"].Rows[lbTeams.SelectedIndex]["Eight"] =
cbLineupName[7].SelectedValue;
DataSet.Tables["teams"].Rows[lbTeams.SelectedIndex]["Nine"] =
cbLineupName[8].SelectedValue;
Jun 4 '07 #1
5 1520
Plater
7,872 Expert 4TB
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_change event gets fired on a databind, which in turn fires off the "populate all my combo boxes" dealy.
Jun 4 '07 #2
Thanks a lot for the quick reply. I will look at that possibility.
Jun 4 '07 #3
On brief inspection that appears to be exactly what is happening. Thanks a lot. :-)
Jun 4 '07 #4
Plater
7,872 Expert 4TB
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
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 SelectedIndexChanged 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
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...
2
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...
8
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
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...
2
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...
3
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...
1
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...
4
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...
5
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
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...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.