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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:55:57+00:00 2026-06-08T20:55:57+00:00

I have a page with a number of fields on it that I’m using

  • 0

I have a page with a number of fields on it that I’m using to create a new class record called Account. One of the fields is a currency code that is set via a combobox. The combobox is bound to a datatable with an id and a description. I’m trying to use binding so that the selectedvalue of the combobox automatically updates the currency id of the Account class. So far no joy…

Class definition:

class Account : IDataErrorInfo
{
    public String Name { get; set; }
    public int CurrencyID { get; set; }
    public int BankID { get; set; }
    public String AccountNumber { get; set; }
    public decimal OpeningBalance { get; set; }

 ... other definitions for validation handling ...

}

Combobox definition:

<ComboBox x:Name="cboCurrency" Grid.Column="1" Grid.Row="1" Width="250" HorizontalAlignment="Left" 
     SelectedValue="{Binding Path=Account.CurrencyID, UpdateSourceTrigger=LostFocus, ValidatesOnDataErrors=True, NotifyOnValidationError=true}"
     ToolTip="{Binding ElementName=cboCurrency, Path=(Validation.Errors)[0].ErrorContent}"/>

Page constructor:

public AccountAdd()
{
    InitializeComponent();

    base.DataContext = new Account();

    // Load the Currency combo with the list of currencies
    //
    cboCurrency.DisplayMemberPath = "Name";
    cboCurrency.SelectedValuePath = "_id";
    cboCurrency.ItemsSource = _DBUtils.getCurrencyList().DefaultView;


}

Save Code:

private void btnAccountOK_Click(object sender, RoutedEventArgs e)
{
    Account newAccountRec = (Account)base.DataContext;

    int newid = _DBUtils.AddAccount(newAccountRec);
}
  • 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-08T20:56:00+00:00Added an answer on June 8, 2026 at 8:56 pm

    Since the ComboBox’s DataContext is set to an Account instance, its SelectedValue should bind to CurrencyID, not Account.CurrencyID:

    <ComboBox SelectedValue="{Binding Path=CurrencyID, ...}" ... />
    

    Also (if your datatable is a DataTable) create a collection of objects with appropriate properties from each table row for the ComboBox’s items, as suggested by blindmeis:

    cboCurrency.DisplayMemberPath = "Name";  
    cboCurrency.SelectedValuePath = "Id";  
    cboCurrency.ItemsSource =
        _DBUtils.getCurrencyList().Rows.Cast<DataRow>().Select(
            row => new { Name = row["Name"], Id = row["_id"] });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have an advanced search page that searches a number of fields in
I have one form in JSP. I have some input fields in that page,
I have a page that has 50 elements with the same class fields which
I have a page that has a large image on it with a number
I have two tables, one contains the page/heading number and the heading text, the
I have a dynamic page that gets a certain number of results for rooms
I have a number of elements on a web page, that are scattered, meaning
I have n number of select elements in an html page that are used
In my registration page I have land line phone number and mobile number fields.
serializeArray() does not pick up form fields that have been added after page load

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.