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

  • Home
  • SEARCH
  • 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 5928711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:19:27+00:00 2026-05-22T14:19:27+00:00

I am having trouble databinding to a Combobox’s SelectedValue and Text properties. Here is

  • 0

I am having trouble databinding to a Combobox’s SelectedValue and Text properties. Here is the relevant code snippet:

DataTable dt1 = DataAccess.GetLoanPurposes();
ddLoanPurpose.DisplayMember = "Name";
ddLoanPurpose.ValueMember = "Value";
ddLoanPurpose.DataBindings.Add("Text", _scenario, "LoanPurposeString", false);
ddLoanPurpose.DataBindings.Add("SelectedValue", _scenario, "LoanPurpose", false);            
ddLoanPurpose.DataSource = dt1;

I can bind to either Text or SelectedValue and everything works brilliantly. The trouble comes when I try to bind to both. Only the first Databinding works (Text to LoanPurposeString in the example above). If I switch the order of the Databinding…

ddLoanPurpose.DataBindings.Add("SelectedValue", _scenario, "LoanPurpose", false);
ddLoanPurpose.DataBindings.Add("Text", _scenario, "LoanPurposeString", false);

…then I lose the binding of Text to LoanPurposeString but now SelectedValue binds to LoanPurpose. So my question is twofold: Why don’t both of the bindings wire up to my _scenario object and why does the order matter?

  • 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-05-22T14:19:27+00:00Added an answer on May 22, 2026 at 2:19 pm

    Databinding to two different properties doesn’t seem to be supported (at least not based on my research). In this particular instance, the best solution is to combine the separate properties in my _scenario object (LoanPurpose and LoanPurposeString) into a single KeyValuePair property.

    public KeyValuePair<string, string> LoanPurpose { get; set; }
    

    I just need to make sure that the ValueMember variable in the DataSource is a KeyValuePair. So something like…

    DataTable dt = new DataTable();
    dt.Columns.Add(new DataColumn("Name", typeof(string)));
    dt.Columns.Add(new DataColumn("Value", typeof(KeyValuePair<string, string>)));
    DataRow dRow = dt.NewRow();
    dRow["Name"] = "Eric";
    dRow["Value"] = new KeyValuePair<string, string>("1", "Eric");
    dt.Rows.Add(dRow);
    

    The binding syntax will be the same as in my original question, the only difference is that the ValueMember is now a KeyValuePair object instead of a string.

    ddLoanPurpose.DisplayMember = "Name";
    ddLoanPurpose.ValueMember = "Value";
    ddLoanPurpose.DataSource = dt;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having trouble databinding a TextBox.Text property to a object's method. The idea
I am following the searchable gridview code listed HERE . I am having trouble
I am having trouble accessing the data field. I receive the error: Databinding methods
I am having some serious trouble creating a WPF TreeView with an Object databinding.
Having trouble linking the Stomp.framework into an iPhone SDK application. http://code.google.com/p/stompframework/ I follow the
Having trouble with the following segment of code. I'm getting a parameter count mismatch.
I've been having trouble with some databinding with WPF. I have a class to
So I'm trying to use the TagLib library with Databinding but I'm having trouble
Having trouble getting the javascript alert to display from my code behind. c# -
Having trouble finding a solution for my situation here. Sorry if this has been

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.