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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T17:26:31+00:00 2026-05-12T17:26:31+00:00

I am looking for best-practices to display the value of foreign-key in a BindingSource.

  • 0

I am looking for “best-practices” to display the value of foreign-key in a BindingSource.

Sample data:

PetID---PetName---PetTypeID
1---Tom---1
2---Jerry---2


PetTypeID---PetType
1---Cat
2---Mouse

I have a Pet class and Pet form. The following code is on the Pet form to return data from the database as a Pet collection and bind the data:

private BindingSource PetBindingSource = new BindingSource();
PetBindingSource.DataSource = Pet.GetPets();

txtPetName.DataBindings.Add(new Binding("Text", PetBindingSource, "PetName"));
txtPetType.DataBindings.Add(new Binding("Text", PetBindingSource, "PetTypeID"));

With this current example, txtPetType will show the PetTypeID (1 or 2), but I want it to display the actual value (Cat or Mouse).

So, what are some best-practices to handle something like this? Add a new property to the Pet class? Join the two tables in the stored procedure to return the value? Other options?

Note: PetName is editable, while PetTypeID will be read-only in this instance, so I’d like to rule out a combo box.

Explanations, examples, reading resources would all be much 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-12T17:26:31+00:00Added an answer on May 12, 2026 at 5:26 pm

    A facade property is the easiest option – especially if it is readonly; just add a property (in a partial class if the type is generated) that walks the relation. There are other routes, though. You can write a TypeConverter and decorate the property with it; this is a pain for generated types, though (since you can’t add an attribute to a member declared in a separate partial class file). You can also use custom property models (ICustomTypeDescriptor/TypeDescriptionProvider), but these would be massively overkill just for this.

    I can expand on any of these as necessary… but most (except the first) are lots of work…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am looking for best practices of avoiding constructor injection overuse. For example I
I'm looking for best practices here. Sorry. I know it's subjective, but there are
I am using the NHibernate.Search assembly and am looking for best practices around using
I am looking for ways / best practices on testing methods defined in an
Web.Config? Website properties? I'm looking for suggestions/best practices with reasons you recommend them.
Looking for some resources on SOA / BPEL best practices. Specially BPEL.
I'm looking for info on best practices for a fire and forget asp.net mvc
I’m looking for recommendations and best practices for applying signed assemblies in an organization
I'm looking for a good summary of best practices for working with TFS source
I am looking for a PHP PDO full working example with best practices for

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.