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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:26:36+00:00 2026-05-18T00:26:36+00:00

I am building an MVC application and am designing a custom model binder for

  • 0

I am building an MVC application and am designing a custom model binder for a class; Essentially one of the fields of the model is an object that exists in the database, but it is proving very difficult to associate this with the appropriate objects in HTML. (since a select list will only let me pick an int/string field, I really can’t store an ‘object’ as the ‘value’ of a Select List).

I was thinking of using the Id stored in a select list to lookup the object in my database in my Model Binder – but a colleague of mine told me this was generally a bad idea. Is this true, and if so, what other options do I have?

  • 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-18T00:26:37+00:00Added an answer on May 18, 2026 at 12:26 am

    Seems like a subjective question but I think it is acceptable to call the repository in the binder. My backup is the excellent book MVC in Action 2. They have a short section on Model Binders. Below is quote which discusses the idea of calling the database in the binder (emphasis added):

    Most of the time, this action
    parameter is the primary key of the
    object or another unique identifier,
    so instead of putting this repeated
    data access code in all our actions,
    we can use a custom model binder that
    can load the stored object before the
    action is executed.
    Our action can
    then take the persisted object type as
    a parameter instead of the unique
    identifier.

    Which makes sense when if you think that the whole point of the model binder is map your view to the underlying domain model. Their example code demonstrates repository calls in the binder as well.

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

Sidebar

Related Questions

I'm building an ASP.NET MVC application with a form that needs validation. The majority
I'm looking into building an ASP.NET MVC application that exposes (other than the usual
I am building a multi-layered application that has an ASP.NET MVC web application. It
I am building an MVC application in which I am reading a list of
I'm building a MVC web application (using the Spring MVC framework), and I'm a
I'm currently building a Spring MVC application. I was looking to use JSP pages
I'm building my first ASP.NET MVC application and I am having some troubles with
I'm am building my asp.net web application using MVC (Preview 5), and am also
I am currently building an application using ASP.NET MVC. The data entry pages are
I'm building an ASP.Net MVC website. Rather than have everything in one project, I've

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.