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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:32:40+00:00 2026-05-23T05:32:40+00:00

I am trying to create a binding source to my binding navigator that will

  • 0

I am trying to create a binding source to my binding navigator that will be able to show all branches within a specific bank.

The statement that gets the datasource is as follows

branchMasterBindingSource.DataSource = Program.Kernel.Get<IBranchMasterService>().GetAllBranchMasters();

However, this pulls all branches regardless of the banks they belong to.

I need to know how to change this so that it gets AllBranchMasters where a field in the database (“U_bank_code”) is equals to a combobox named “cb_bank_code”

Extra code is below:

private void cb_bank_code_SelectedIndexChanged(object sender, EventArgs e)
       {    

           branchMasterBindingSource.DataSource = null;
           branchMasterBindingSource.DataSource = Program.Kernel.Get<IBranchMasterService>().GetAllBranchMasters();

           //clear textfields after input
           lbl_show_bank_name.Text = string.Empty;
           txt_branch_code.Text = string.Empty;
           txt_branch_name.Text = string.Empty;
           txt_swift_sort_code.Text = string.Empty;
           txt_address_1.Text = string.Empty;
           txt_address_2.Text = string.Empty;
           txt_comments.Text = string.Empty;

           var bankMasterService = Program.Kernel.Get<IBankMasterService>();

           var bankMasters = from bm in bankMasterService.GetAllBankMasters()
                             where bm.U_Bank_code.Trim().Equals(cb_bank_code.Text.Trim(), StringComparison.CurrentCultureIgnoreCase)
                             select bm;

           if (bankMasters.Any(x => x != null))
           {
               var bankMaster = bankMasters.First();

               lbl_show_bank_name.Text = bankMaster.U_Bank_name;

               CbBankCode = bankMaster.U_Bank_code;

           }
           else
           {
               //clear textfields after input
               lbl_show_bank_name.Text = string.Empty;
           }

Im new to C# and dot net and do not know how the syntax to change the statement. Any help appreciated

  • 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-23T05:32:41+00:00Added an answer on May 23, 2026 at 5:32 am

    Although you should look at refactoring your data access methods to do the filtering something like this should do the trick for you

    private void cb_bank_code_SelectedIndexChanged(object sender, EventArgs e)
    {  
       ClearTextfieldsAfterInput();
    
       branchMasterBindingSource.DataSource = GetSelectedBranchMasters();
    
       var bankMasters = GetSelectedBankMaster();
    
       if (bankMasters.Any(x => x != null))
       {
           var bankMaster = bankMasters.First();
    
           lbl_show_bank_name.Text = bankMaster.U_Bank_name;
           CbBankCode = bankMaster.U_Bank_code;
       }
       else
       {
           //clear textfields after input
           lbl_show_bank_name.Text = string.Empty;
       }
    }
    
    private IEnumerable<BankMaster> GetSelectedBankMaster()
    {
        var selectedBank = cb_bank_code.Text.Trim();
        return Program.Kernel.Get<IBankMasterService>()
            .GetAllBankMasters()
            .Where(bm => bm.U_Bank_code.Trim().Equals(selectedBank, StringComparison.CurrentCultureIgnoreCase))
            .ToList();
    }
    
    private IEnumerable<BranchMaster> GetSelectedBranchMasters()
    {
        var selectedBank = cb_bank_code.Text.Trim();
        return Program.Kernel.Get<IBranchMasterService>()
            .GetAllBranchMasters()
            .Where(branch => string.Equals(branch.U_bank_code, selectedBank, StringComparison.CurrentCultureIgnoreCase))
            .ToList();
    }
    
    private void ClearTextfieldsAfterInput()
    {
       lbl_show_bank_name.Text = "";
       txt_branch_code.Text = "";
       txt_branch_name.Text = "";
       txt_swift_sort_code.Text = "";
       txt_address_1.Text = "";
       txt_address_2.Text = "";
       txt_comments.Text = "";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having an issue with a binding that I'm trying to implement. It will
I am trying to create a Multi-Language WPF program that will load it's languages
I am trying to create a preference pane which will reside within system preferences.
I am trying create a WCF service that leverages the WPF MediaPlayer on the
Trying to create my first iPhone app that would play back audio. When I
Trying to create a small monitor application that displays current internet usage as percentage
I'm trying to build a pipeline with gst-launch in Windows 7 that will view
I'm trying to create a binding to libpython using scheme's FFI. To do this,
I'm trying to create python bindings for source-highlight-qt using sip. I'm working on ubuntu
I'm trying to create a reusable UserControl in WPF that has a Label and

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.