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 8326435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:45:36+00:00 2026-06-09T00:45:36+00:00

Running a project with linq to sql model, and binding my combos to bindingsource

  • 0

Running a project with linq to sql model, and binding my combos to bindingsource controls, I have two comboBoxes, first shows a table which shows database tables names (ID, TableName) and the second should be bound to the selected table in the first combo, I tried this code:

        private void ComboBox1_TextChanged(object sender, EventArgs e)
    {
        if (ComboBox1.Text == "Customers")
        {
            var qry = (from u in dc.Customers
                       select u).ToList();
            comboBox2.ValueMember = "CustomerID";
            comboBox2.DisplayMember = "CompanyName";
            comboBox2.DataSource = qry;
        }
        if (ComboBox1.Text == "Suppliers")
        {
            var qry = (from u in dc.Suppliers
                       select u).ToList();
            comboBox2.ValueMember = "SupplierID";
            comboBox2.DisplayMember = "CompanyName";
            comboBox2.DataSource = qry;
        }
    }

With the code above I can show the first combo items, I can show also the second combo items by default, but when I change the first combo content I get error at comboBox2.ValueMember = “SupplierID”; : System.ArgumentException was unhandled
Message=Link to the new Value member impossible. Please how can I reset the combobox2.ValueMember to the new field name?

  • 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-09T00:45:39+00:00Added an answer on June 9, 2026 at 12:45 am

    It is necessary to initialize the combobox properties before changing its ValueMember, like this:

            **comboBox2.DataSource = null;**
            if (ComboBox1.Text == "Customers")
            {
                var qry = (from u in dc.Customers
                           select new { u.CustomerID, u.CompanyName }).ToList();
                comboBox2.ValueMember = "CustomerID";
                comboBox2.DisplayMember = "CompanyName";
                comboBox2.DataSource = qry;
            }
            if (ComboBox1.Text == "Suppliers")
            {
                var qry = (from u in dc.Suppliers
                           select new { u.SupplierID, u.CompanyName }).ToList();
                comboBox2.ValueMember = "SupplierID";
                comboBox2.DisplayMember = "CompanyName";
                comboBox2.DataSource = qry;
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

.Net MVC application also running Linq-to-SQL. I have seen many articles on grids that
I have a new ASP.NET MVC project (my first), and I had been running
I have a WPF Linq-to-SQL project which I have been developing using MS Visual
I have a little project where I'm running MVC3. I use LINQ to fetch
I have several instances of my project running on my server, like so: http://0.0.0.0/one
Let's suppose we have an open source project running in a server. Is there
I am creating a small commercial web project running Apache/WSGI/Django/MySQL. I have a development
I have trying to learn MVC4 Web API. I am running my project from
I have a project which can only be deployed on a server running .NET
When I am running the project locally and have not got resque running I

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.