Home All Groups Group Topic Archive Search About

three combos, same dataset

Author
6 Jan 2006 8:18 PM
BrianDH
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

Author
6 Jan 2006 9:25 PM
Marina
Set each combo to have its own BindingContext.

Show quoteHide quote
"BrianDH" <Bria***@discussions.microsoft.com> wrote in message
news:BE69F70E-8049-4109-9531-662AD67A61FD@microsoft.com...
> 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
Author
6 Jan 2006 10:10 PM
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
Author
9 Jan 2006 4:19 PM
BrianDH
Thank you that worked!

Show quoteHide quote
"BrianDH" wrote:

> 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