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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:46:00+00:00 2026-05-31T18:46:00+00:00

I have 2 tables in the database carrier and vendor . vendor has a

  • 0

I have 2 tables in the database carrier and vendor. vendor has a foreign key of Carrier_Id. When the user want add a vendor, the user will select a carrier from a combobox where the valve from carrier table.

The problem I facing now is that,I don’t know how to get the valve from combobox so that I can insert it into the database.

I use this code to get valve from carrier table to show in the combobox.

MyinvoiceDataDataContext contect = new MyinvoiceDataDataContext();
var st = from s in contect.Carriers
select new { s.CarrierID, s.CarrierName};
comVendorCarrier.ItemsSource = st;
comVendorCarrier.DisplayMemberPath = "CarrierName";
comVendorCarrier.SelectedValuePath = "CarrierID";
  • 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-31T18:46:01+00:00Added an answer on May 31, 2026 at 6:46 pm

    To get the value of this combobox (i.e. the selected carrier), all you need is just use the two properties SelectedValue to get the CarrierId or SelectedText to get the value (i.e. CarrierName).
    For example, you could get the id of the selected carrier by using:

    int SelectedCarrierId = int.parse(comVendorCarrier.SelectedValue.ToString());
    

    Or if you need the CarrierName you should use:

    string CarrierName = comVendorCarrier.SelectedText;
    

    Edit: Assuming that your tables have the following structre:

    Carrier:

    • CarrierId.
    • CarrierName.

    Vendor:

    • VendorId.
    • CarrierId: a foreign key references Carriers(CarrierId).
    • VendorName.

    These two tables should be mapped in your .dbml file to two entities Vendor and Carrier, in which the Vendor class has a property of type Carrier that represents the foreign key CarrierID.

    Then in order to view CarrierName in the vendors list, you can do this:

    var vendorsList = _db.Vendors 
                         .Select( vendor => new
                         {
                             VendorId = vendor.Id,
                             VendorName = vendor.Name,
                             CarrierName = vendor.Carrier.Name
                         });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three database tables with foreign keys to each other, and I want
I have 2 tables in database User and Link. The userid is a foreign
I have two database tables with the following structure: actions: action_id int(11) primary key
I have an Access database that has two tables that are related by PK/FK.
In my Rails application, I have a variety of database tables that contain user
I have got a datatable with records from two different database tables. Each of
Suppose I have database tables: user id username plan 1 ahmad Note: plan is
I have 2 tables in database:tbleducation,tblemployee.Anyway for table tblemployee, I have fields: employeeID,employeeName....I want
I have four tables in database. person(Perid ,firstname , lastname , gender) Research (Resid
I have two database tables, 1st is the TABLE_GLOBAL_PRODUCTS where all products information are

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.