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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:05:27+00:00 2026-06-11T07:05:27+00:00

I’m writing a simple first app using Winforms, C#, VS2010, and Entity Framework. Basically,

  • 0

I’m writing a simple first app using Winforms, C#, VS2010, and Entity Framework. Basically, I have a rich DB I’m tapping, and I’ve already set up the framework, successfully enough to populate a DataGridView control with a subset of the Work Order table.

Now, I want to place a combo box on the form (“cbProjectID”) whose value is ProjectID and DisplayValue is ProjectNbr. I only want to put projects in the combo box list that are related to WorkOrders, and only unique ProjectIDs within that set (a project may have dozens of work orders….)

I’m assuming I need to generate a list from EF, using LINQ. I’m pretty new at LINQ, and I’m not figuring it out…Here’s my code so far…

using System;
using CPASEntityFramework;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace BrowseWorkOrders
{
    public partial class BrowseWOs : Form
    {
        public BrowseWOs()
        {
            InitializeComponent();
        }

        private void BrowseWOs_Load(object sender, EventArgs e)
        {
            var context = new CPASEntities();
            var query = context.tblWorkOrders.Where(c => c.ProjectID==8);
            tblWorkOrderBindingSource.DataSource = query.ToList();

        //  Now, I want to load up the Combo Box with all the projects in the Work Order Table

        }
    }
}

I’ve been through the net trying to find a method I understand, but I’m failing. Perhaps someone can help me out. Here’s my Datasource (I assume I should NOT use tblProject, but instead use the tblProject inside tblWorkOrder in order to get my subset…)

Entity Framework Datasource

Any help and/or guidance would be appreciated.


Here’s the code now…

namespace BrowseWorkOrders
{
    public partial class BrowseWOs : Form
    {
        public BrowseWOs()
        {
            InitializeComponent();
        }

        private void BrowseWOs_Load(object sender, EventArgs e)
        {
            // Following loads up all Projects into the cbProjectID Combo Box

            var context = new CPASEntities();
            var PrID = context.qryProjectIDNbrDescs.ToList();
            cbProjectID.DataSource = PrID;
            cbProjectID.ValueMember = "ID";
            cbProjectID.DisplayMember = "ProjectNbr";
        }

        private void cbProjectID_SelectedIndexChanged(object sender, EventArgs e)
        {
            var context = new CPASEntities();
            var query = context.tblWorkOrders.Where(c => c.ProjectID == (int)cbProjectID.SelectedValue).ToList();
            tblWorkOrderBindingSource.DataSource = query;
        }
    }
}
  • 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-11T07:05:29+00:00Added an answer on June 11, 2026 at 7:05 am

    You need the tblProject on the top because the other is for a single WorkOrder only. However, you need to filter the list with those who have at least on WorkOrder:

    var projects = context.tblProjects.Where(p => p.tblWorkOrders.Any()).ToArray();
    cbProjectID.DataSource = projects;
    cbProjectID.ValueMember = "ProjectID";
    cbProjectID.DisplayMember = "ProjectNbr";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I'm making a simple page using Google Maps API 3. My first. One marker
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am writing an app with both english and french support. The app requests
I have thousands of HTML files to process using Groovy/Java and I need to
I am using Paperclip to handle profile photo uploads in my app. They upload
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.