Click here to Skip to main content
15,891,868 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi Guys, I have another question, this time i fear i may have over complicated it. Apologies in advance.

Brief Project Description: I have a Database containing two tables. The Customers Table has four fields, "Name", "Address", "Phone Number" and "Customer ID". The Jobs Table has three fields, "Customer ID", "Description" and "Due Date". I have also associated "Customer ID" in both tables with each other in the DataContext.dbml file.

Window1.xaml has two ListBoxes, the first displays all the Customers from the first table and the second ListBox displays all the Jobs from the second table.

At the moment the second table is displaying all the jobs, i would like to have it so that when a customer in Table 1 is selected, Table 2 displays only jobs with the same Customer ID as the one selected.

Question: Can i filter information from a table based on a information from another table?

Once again, thank you all for your help in advance,
Alex
Posted

here is the code
In Jobs dropdown data bind
C#
    ddlJobs.DataSource =returnFilteredData(customerid) ;
    ddlJobs.DataTextField = "Description";
    ddlJobs.DataValueField = "Id";
    ddlJobs.DataBind();


public IEnumerable returnFilteredData(int customerid)
{
    //_db is the DataContext(your dbml)
    return from jobs in _db.tbl_JOBS
           where jobs.customerid == customerid
           select jobs;
}


Modify the code according to the control you are binding
 
Share this answer
 
v3
That code is ASP.NET not WPF.

I can work up a solution either way , but what is it that need ASP.NET or WPF?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900