Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7951905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:42:11+00:00 2026-06-04T02:42:11+00:00

UPDATED I have an application that updates a combobox based on the values selected

  • 0

UPDATED

I have an application that updates a combobox based on the values selected from another combobox.E.g List of states combobox will be populated based on the country selected from the “country” combobox.The datasource for the state combobox is a dataset based on a MySQL database. The issue is that if a country is selected first, the state combobox loads fine,but if i select another country,the state combobox is populated with:

  System.Data.DataViewManagerListItemTypeDescriptor

I researched and found out that the issue has to do with me being unable to update the datasource of the combobox,but i have to do this because the values are stored in different tables,and require different queries. So, how can i clear the datasource/resolve this issue?.

I have updated the post to add my code below(first is the code for the first combobox which populates the next based on values selected here:

  private void cboDisp1_SelectedIndexChanged(object sender, EventArgs e)
    {

        cboProd1.Enabled = false;
        cboProd1.Invalidate();
        string dispensation1;
        dispensation1 = cboDisp1.SelectedValue.ToString();
        if (dispensation1 == "1")
        {

        }
        else
        { cboProd1.Enabled = true;
        LoadDispensationCode(dispensation1,"1");
         }
    }

This code shows part of the method that populates the second combobox:

 private void LoadDispensationCode(string text_id,string line_no)
    {
        string txt_id=text_id;
        string ln_no=line_no;
        //MessageBox.Show(txt_id, "Value");
        txt_id = text_id;
        if (txt_id == "1")
        { }
        if
            (txt_id == "2")
        { LoadConsultation("1","1"); }
        if(txt_id=="3")
        {
            LoadDrug(ln_no);
            }.......

This code shows the method that fills the dataset based on the query to the MySQL database, and loads the combobox.

      private void LoadDrug(string line_no)
    {  
        string ln_no;
        ln_no = line_no;
        //MessageBox.Show(ln_no,"value of text");
        if (ln_no =="1")
        {
         try
            {
                MySqlConnection connection = HopeDB.GetConnection();
                String selectStatement = "Select id,code from drugs order by id";
                MySqlCommand command = new MySqlCommand(selectStatement, connection);
                MySqlDataAdapter adapter = new MySqlDataAdapter();
                DataSet ds = new DataSet();
                adapter.SelectCommand = command;
                adapter.Fill(ds, "drugs");
                adapter.TableMappings.Add("Table", "drugs");

                   cboProd1.DisplayMember = "drugs.code";
                cboProd1.ValueMember = "drugs.id";
                cboProd1.DataSource = ds;
                connection.Close();

            }
            catch (Exception ex)
            { MessageBox.Show(ex.Message, ex.GetType().ToString()); }

        } 

    }

This code is another method that generates another dataset.

               private void LoadVaccine(string line_no)
    {

        string ln_no = line_no;
        if (ln_no == "1")
        {

            try
            {
                MySqlConnection connection = HopeDB.GetConnection();
                String selectStatement = "Select id,code from vaccines order by id";
                MySqlCommand command = new MySqlCommand(selectStatement, connection);
                MySqlDataAdapter adapter = new MySqlDataAdapter();
                DataSet ds = new DataSet();
                adapter.SelectCommand = command;
                adapter.Fill(ds, "vaccines");
                adapter.TableMappings.Add("Table", "vaccines");

                cboProd1.DisplayMember = "vaccines.code";
                cboProd1.ValueMember = "vaccines.id";
                cboProd1.DataSource = ds;
                //cboStateIDFNo.Enabled =false;
                //cboVisitType.Enabled =false;
                //cboStatus.Enabled = false;
                connection.Close();
            }
            catch (Exception ex)
            { MessageBox.Show(ex.Message, ex.GetType().ToString()); }
        } 
    }

As mentioned earlier,i need help on updating the combobox with fresh data from a different dataset when the first combobox is changed,and another method is called.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T02:42:13+00:00Added an answer on June 4, 2026 at 2:42 am

    I don’t think you can bind ComboBoxs to a dataset, because you can’t specify the DataMember. That being the case, you should instead set the ComboBox.DataSource to the datatable in question and then set the display/value members:

    cboProd1.DataSource = ds.Tables["drugs"];
    cboProd1.DisplayMember = "code";
    cboProd1.ValueMember = "id";
    

    Give that a try and let us know.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an AJAX based application that updates a text field in a form
I have an application that makes use of frequently updated lists. So for example,
I have an application written in Delphi that adds / updates contacts in outlook.
I have a windows forms application that reads and updates an XML file with
I have a certain web application that makes upwards of ~100 updates to an
I have a model function that updates a user in my CodeIgniter application: //
I need to create a plug-in that updates an application. Look, I have a
I have an application that i run daily to send contract updates to CRM
I have a System.Timers.Timer that updates my win form application components in every 5
In my application I have a DataGridView control that displays data for the selected

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.