three combos, same dataset

G

Guest

Hi

I have a form with multi-tabs, and on each tab I have a one combo that has
the same values.
I populate all 3 combo with the same one datacall/dataset
My problem is: when I make a value selection change to one, it changes the
other 2 combos on the other 2 tabs.

Is there a way to make one datacall, but have three seperate acting controls?

At the moment I have to call the same data call three time.

//Code Example
DataSet selectDataSet = DataCalls.RetrieveTypeOfFood();
DataSet menuDataSet = DataCalls.RetrieveTypeOfFood();
DataSet newDataSet = DataCalls.RetrieveTypeOfFood();

//*************************************
DataView dv = new DataView();
DataRow dr;
dr = selectDataSet.Tables[0].NewRow();
dr["Code"] = " - Select Type - ";
dr["CodeID"] = 0;
selectDataSet.Tables[0].Rows.Add(dr);
dv.Table = selectDataSet.Tables[0];
dv.Sort = "Code ASC";
SelectTypeComboBox.DisplayMember = "Code";
SelectTypeComboBox.ValueMember = "CodeID";
SelectTypeComboBox.DataSource = dv;

//**************************************
DataView mdv = new DataView();
DataRow mdr;
mdr = menuDataSet.Tables[0].NewRow();
mdr["Code"] = " - Select Type - ";
mdr["CodeID"] = 0;
menuDataSet.Tables[0].Rows.Add(mdr);
mdv.Table = menuDataSet.Tables[0];
mdv.Sort = "Code ASC";
MenuTypeComboBox.DisplayMember = "Code";
MenuTypeComboBox.ValueMember = "CodeID";
MenuTypeComboBox.DataSource = mdv;

//**************************************
DataView ndv = new DataView();
DataRow ndr;
ndr = newDataSet.Tables[0].NewRow();
ndr["Code"] = " - Select Type - ";
ndr["CodeID"] = 0;
newDataSet.Tables[0].Rows.Add(ndr);
ndv.Table = newDataSet.Tables[0];
ndv.Sort = "Code ASC";
NewTypesComboBox.DisplayMember = "Code";
NewTypesComboBox.ValueMember = "CodeID";
NewTypesComboBox.DataSource = ndv;

Thanks
Brian
 
C

Cor Ligthert [MVP]

Brian,

I never saw it this way, however I don't know why this is not working, can
you try it like this.

DataView ndv = new DataView(newDataSet.Tables[0]);
DataRow ndr;
ndr = newDataSet.Tables[0].NewRow();
ndr["Code"] = " - Select Type - ";
ndr["CodeID"] = 0;
newDataSet.Tables[0].Rows.Add(ndr);
\\\ ndv.Table = newDataSet.Tables[0];
ndv.Sort = "Code ASC";
NewTypesComboBox.DisplayMember = "Code";
NewTypesComboBox.ValueMember = "CodeID";
NewTypesComboBox.DataSource = ndv;
Be aware that you are probably adding 3 times a row to the same datatable.

In addition probably it is better to ask this in the CSharp newsgroup, not
that we are not able to help you, however a Csharp question does not look so
well if there is a search done in this newsgroup.

I hope this helps,

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top