Yes, I think you will have to.
Either that or manually loop through an add your data to the comboboxes so they're not "bound" to a datasource.
Although I recomend making copies of the dataset
I think I am either misunderstand or misusing datasets, maybe you can clarify this for me;
On my form, I have now 13 questions; the questions are sets in labels and the answers will be collected from comboboxes and textboxes. The labels and textboxes give me no problems (so far). But the comboboxes need options, and I wanted to have the data coming from a datatable in case a new option is desired, then I would not have to modify the form, just add the new option in the database's table.
So correct me if I'm wrong, I would have to create 13 DataSets
- DataSet comboxDS_1 = new DataSet();
-
DataSet comboxDS_2 = new DataSet();
-
...
-
DataSet comboxDS_13 = new DataSet();
from the same query to provide the same options to the 13 comboboxes in order to keep their selected values different from each other.
What I want is unbounded datasources... I was able to do this in Access but I still need to learn how to do this with .NET
just for the fun of it, here is my code that fills my controls ...
and thank you for the time you take answering my questions
-
void load_controls()
-
{
-
try
-
{
-
//labels
-
DataSet labelDS = new DataSet();
-
string labelSQL = @"SELECT * FROM tbl_Label WHERE ynLabel_archive = false " +
-
" AND intLabel_phase = 1 ORDER BY intLabel_id ASC; ";
-
labelDS = classObj.GetDataSet(labelSQL);
-
// object casting
-
System.Windows.Forms.Label curLabel;
-
int rw = -1;
-
int lastposY = 0;
-
int lastHeight = 0;
-
-
//dropdowns
-
DataSet comboxDS = new DataSet();
-
string comboxSQL = @"SELECT * FROM tbl_Status; ";
-
comboxDS = classObj.GetDataSet(comboxSQL);
-
// object casting
-
System.Windows.Forms.ComboBox curCombox;
-
-
//textbox
-
System.Windows.Forms.TextBox curTextBox;
-
foreach (object obj in this.Controls)
-
{
-
switch (obj.GetType().ToString())
-
{
-
case "System.Windows.Forms.ComboBox":
-
//P1_Q1_complete_box.DataSource = newDS.Tables[0];
-
curCombox = ((System.Windows.Forms.ComboBox)obj);
-
if (curCombox.Name.IndexOf("_complete_box") > 0)
-
{
-
//MessageBox.Show("curCombox:" + curCombox.Name);
-
curCombox.DataSource = comboxDS.Tables[0];
-
curCombox.DisplayMember = "strStatus_en";
-
curCombox.ValueMember = "intStatus_id";
-
curCombox.Text = "select";
-
}
-
break;
-
-
case "System.Windows.Forms.Label":
-
curLabel = ((System.Windows.Forms.Label)obj);
-
//only apply to certain labels
-
if (curLabel.Name.IndexOf("_box") > 0)
-
{
-
//this sets the Question ID
-
rw = Convert.ToInt32(getQuePos(curLabel.Name)) - 1;
-
curLabel.Text = labelDS.Tables[0].Rows[rw].ItemArray[2].ToString();
-
curLabel.Text += "\n";
-
curLabel.Text += "________________________________________________________________________";
-
-
}
-
break;
-
-
case "System.Windows.Forms.TextBox":
-
curTextBox = ((System.Windows.Forms.TextBox)obj);
-
//...
-
break;
-
}//end of switch
-
-
}//End of foreach
-
-
}//End of try
-
catch (Exception ex)
-
{
-
MessageBox.Show("load_controls:" + ex.Message + "\n" + ex.Source + "\n" + ex.TargetSite);
-
}
-
}