By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,825 Members | 1,055 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,825 IT Pros & Developers. It's quick & easy.

C# - Three Combobox - Databinding - DefaultView Problem

P: 3
I face a problem, please help.
Error I hit when there are three combobox.
Please refer the code with italic characters.

this.comboBox1.DataSource = this.dataSet11.Tables["PANEL"];
this.comboBox2.DataSource = this.dataSet11.Tables["PANEL"].DefaultView;
this.comboBox3.DataSource = dataSet11.Tables["PANEL"];[/


The combobox1 value is as same as combobox3 value.
The combobox2 value is different because Table[""].DefaultView is added.
where combobox1,2,3 values are different at all.




BindingManagerBase bindManager1;
BindingManagerBase bindManager2;
BindingManagerBase bindManager3;
BindingManagerBase bindManager4;


public Form1()
{
InitializeComponent();
}


private void Form1_Load(object sender, EventArgs e)
{
cn1 = new OracleConnection(strConn);

using (cn1)
{
cn1.Open();

//da1 = new OracleDataAdapter("SELECT CLIENTGRPNO, DESCRIPTION, OTHERDESC, PANELCODE, INCLUDEBANDED, BANDEDFLAG, OFFERITEM, OUTPUTDIR, CAUSALPANELCODE, AUDITPANELCODE, MBDTAG_ATTRNO FROM RRS.CLIENT_GROUP_MASTER ORDER BY CLIENTGRPNO", cn1);
da1 = new OracleDataAdapter("SELECT CLIENTGRPNO, DESCRIPTION, OTHERDESC, OUTPUTDIR, PANELCODE, CAUSALPANELCODE, AUDITPANELCODE FROM RRS.CLIENT_GROUP_MASTER ORDER BY CLIENTGRPNO", cn1);
da1.Fill(this.dataSet11, "CLIENT_GROUP_MASTER");

da2 = new OracleDataAdapter("SELECT CLIENTGRPNO, CLIENTCODE FROM RRS.CLIENT_GROUP_DETAIL ORDER BY CLIENTGRPNO", cn1);
da2.Fill(this.dataSet11, "CLIENT_GROUP_DETAIL");

da3 = new OracleDataAdapter("SELECT CLIENTCODE, CLIENTNAME FROM RRS.CLIENT_MASTER ORDER BY CLIENTCODE", cn1);
da3.Fill(this.dataSet11, "CLIENT_MASTER");

da4 = new OracleDataAdapter("SELECT PANELCODE, DESCRIPTION FROM RRS.PANEL ORDER BY PANELCODE", cn1);
da4.Fill(this.dataSet11, "PANEL");


}

this.comboBox1.DataBindings.Add("SelectedValue", ds, "PANEL.DESCRIPTION");
this.comboBox2.DataBindings.Add("SelectedValue", ds, "PANEL.DESCRIPTION");
this.comboBox3.DataBindings.Add("SelectedValue", ds, "PANEL.DESCRIPTION");



this.comboBox1.DataSource = null;
this.comboBox1.DisplayMember = "DESCRIPTION";
this.comboBox1.ValueMember = "PANELCODE";
this.comboBox1.DataSource = this.dataSet11.Tables["PANEL"];


this.comboBox2.DataSource = null;
this.comboBox2.DisplayMember = "DESCRIPTION";
this.comboBox2.ValueMember = "PANELCODE";
this.comboBox2.DataSource = this.dataSet11.Tables["PANEL"].DefaultView;

this.comboBox3.DataSource = null;
this.comboBox3.DisplayMember = "DESCRIPTION";
this.comboBox3.ValueMember = "PANELCODE";
this.comboBox3.DataSource = dataSet11.Tables["PANEL"];


this.bindManager1 = this.BindingContext[this.dataSet11, "CLIENT_GROUP_MASTER"];
this.bindManager2 = this.BindingContext[this.dataSet11, "CLIENT_GROUP_DETAIL"];
this.bindManager3 = this.BindingContext[this.dataSet11, "CLIENT_MASTER"];
this.bindManager4 = this.BindingContext[this.dataSet11, "PANEL"];

Binding b1 = new Binding("Text", dataSet11, "CLIENT_GROUP_MASTER.CGMaster_Panel.DESCRIPTIO N");
this.comboBox1.DataBindings.Add(b1);
Binding b2 = new Binding("Text", dataSet11, "CLIENT_GROUP_MASTER.CGMaster_CausalPanel.DESCRIPT ION");
this.comboBox2.DataBindings.Add(b2);
Binding b3 = new Binding("Text", dataSet11, "CLIENT_GROUP_MASTER.CGMaster_AuditPanel.DESCRIPTI ON");
this.comboBox3.DataBindings.Add(b3);
}
Dec 12 '07 #1
Share this Question
Share on Google+
2 Replies


P: 3
Hi All,

Regarding the problem I mentioned in post #1, I still need to explain the code I paste in #1.

I use vs2005 wizard to generate four tables in one dataset --"dataSet11" :
1. CLIENT_GROUP_MASTER
2. CLIENT_GROUP_DETAIL
3. CLIENT_MASTER
4. PANEL

and its relation:
Table 1.-> Table 2. = CGMaster_CGDetail (PK = ClientGrpNo, FK = ClientGrpNo)
Table 2.-> Table 3. = CGDetail_CMaster (PK = ClientCode, FK = ClientCode)
Table 1.-> Table 4. = CGMaster_Panel, CGMaster_CausalPanel, CGMaster_AuditPanel.
(PK = panelcode, FK = panelcode)
(PK = causalpanelcode, FK = panelcode)
(PK = auditpanelcode, FK = panelcode)

Besides the explanation, I still have 1 more question.
What should I do if I want to implement master-detail feature into DataGridView:

I prefer to add the code as shown below before "private void Form1_Load(object sender, EventArgs e)" closed:

WHEN I ADD THE CODE BELOW, it works, result as my expected:
this.dataGridView1.DataSource = this.dataSet11.Tables["CLIENT_GROUP_MASTER"];
this.dataGridView1.DataMember = "CGMaster_CGDetail";

BUT, WHEN I ADD THE CODE BELOW, no joy:
this.dataGridView2.DataSource = this.dataSet11;
this.dataGridView2.DataMember = "CLIENT_GROUP_DETAIL.CGDetail_CMaster ";

Thanks all.

Regards,
einsson

I face a problem, please help.
Error I hit when there are three combobox.
Please refer the code with italic characters.

this.comboBox1.DataSource = this.dataSet11.Tables["PANEL"];
this.comboBox2.DataSource = this.dataSet11.Tables["PANEL"].DefaultView;
this.comboBox3.DataSource = dataSet11.Tables["PANEL"];[/


The combobox1 value is as same as combobox3 value.
The combobox2 value is different because Table[""].DefaultView is added.
where combobox1,2,3 values are different at all.




BindingManagerBase bindManager1;
BindingManagerBase bindManager2;
BindingManagerBase bindManager3;
BindingManagerBase bindManager4;


public Form1()
{
InitializeComponent();
}


private void Form1_Load(object sender, EventArgs e)
{
cn1 = new OracleConnection(strConn);

using (cn1)
{
cn1.Open();

//da1 = new OracleDataAdapter("SELECT CLIENTGRPNO, DESCRIPTION, OTHERDESC, PANELCODE, INCLUDEBANDED, BANDEDFLAG, OFFERITEM, OUTPUTDIR, CAUSALPANELCODE, AUDITPANELCODE, MBDTAG_ATTRNO FROM RRS.CLIENT_GROUP_MASTER ORDER BY CLIENTGRPNO", cn1);
da1 = new OracleDataAdapter("SELECT CLIENTGRPNO, DESCRIPTION, OTHERDESC, OUTPUTDIR, PANELCODE, CAUSALPANELCODE, AUDITPANELCODE FROM RRS.CLIENT_GROUP_MASTER ORDER BY CLIENTGRPNO", cn1);
da1.Fill(this.dataSet11, "CLIENT_GROUP_MASTER");

da2 = new OracleDataAdapter("SELECT CLIENTGRPNO, CLIENTCODE FROM RRS.CLIENT_GROUP_DETAIL ORDER BY CLIENTGRPNO", cn1);
da2.Fill(this.dataSet11, "CLIENT_GROUP_DETAIL");

da3 = new OracleDataAdapter("SELECT CLIENTCODE, CLIENTNAME FROM RRS.CLIENT_MASTER ORDER BY CLIENTCODE", cn1);
da3.Fill(this.dataSet11, "CLIENT_MASTER");

da4 = new OracleDataAdapter("SELECT PANELCODE, DESCRIPTION FROM RRS.PANEL ORDER BY PANELCODE", cn1);
da4.Fill(this.dataSet11, "PANEL");


}

this.comboBox1.DataBindings.Add("SelectedValue", ds, "PANEL.DESCRIPTION");
this.comboBox2.DataBindings.Add("SelectedValue", ds, "PANEL.DESCRIPTION");
this.comboBox3.DataBindings.Add("SelectedValue", ds, "PANEL.DESCRIPTION");



this.comboBox1.DataSource = null;
this.comboBox1.DisplayMember = "DESCRIPTION";
this.comboBox1.ValueMember = "PANELCODE";
this.comboBox1.DataSource = this.dataSet11.Tables["PANEL"];


this.comboBox2.DataSource = null;
this.comboBox2.DisplayMember = "DESCRIPTION";
this.comboBox2.ValueMember = "PANELCODE";
this.comboBox2.DataSource = this.dataSet11.Tables["PANEL"].DefaultView;

this.comboBox3.DataSource = null;
this.comboBox3.DisplayMember = "DESCRIPTION";
this.comboBox3.ValueMember = "PANELCODE";
this.comboBox3.DataSource = dataSet11.Tables["PANEL"];


this.bindManager1 = this.BindingContext[this.dataSet11, "CLIENT_GROUP_MASTER"];
this.bindManager2 = this.BindingContext[this.dataSet11, "CLIENT_GROUP_DETAIL"];
this.bindManager3 = this.BindingContext[this.dataSet11, "CLIENT_MASTER"];
this.bindManager4 = this.BindingContext[this.dataSet11, "PANEL"];

Binding b1 = new Binding("Text", dataSet11, "CLIENT_GROUP_MASTER.CGMaster_Panel.DESCRIPTIO N");
this.comboBox1.DataBindings.Add(b1);
Binding b2 = new Binding("Text", dataSet11, "CLIENT_GROUP_MASTER.CGMaster_CausalPanel.DESCRIPT ION");
this.comboBox2.DataBindings.Add(b2);
Binding b3 = new Binding("Text", dataSet11, "CLIENT_GROUP_MASTER.CGMaster_AuditPanel.DESCRIPTI ON");
this.comboBox3.DataBindings.Add(b3);
}
Dec 12 '07 #2

P: 3
Since The dataset11.Table["Panel"] cannot support on more than two combobox objects, create another new Table --eg. dataset11.Table["Panel1"] can solve the problem .... althought this is not the best answer but alternative answer ....
Dec 14 '07 #3

Post your reply

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