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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:29:43+00:00 2026-05-13T11:29:43+00:00

I have having a little trouble wrapping my head around the design pattern for

  • 0

I have having a little trouble wrapping my head around the design pattern for MVC when the data type of the model property is very different than what I wish to display in a form. I am unsure of where the logic should go.

Realizing that I am not really sure how to ask the question I think I will explain it as a concrete example.

I have a table of Invoices with a second table containing the InvoiceDetails. Each of the InvoiceDetail items has an owner who is responsible for approving the charge. A given invoice has one or more people that will eventually sign off on all the detail rows so the invoice can be approved. The website is being built to provide the approval functionality.

In the database I am storing the employee id of the person who approved the line item. This schema provides me a model with a String property for the Approved column.

However, on the website I wish to provide a CheckBox for the employee to click to indicate they approve the line item.

I guess my question is this — how do I handle this? The Model being passed to the View has a String property but the form value being passed back to the Controller will be of the CheckBox type. I see two possible ways…

1) Create a new Model object to represent the form fields…say something like FormInvoiceDetails…and have the business logic query the database and then convert the results to the other type. Then after being submitted, the form values need to be converted back so the original Model objects can be updated.

2) Pass the original InvoiceDetails collection to the View and have code there create render the CheckBox based on the value of the String property. I am still not sure how to handle the submission since I still need to map back the form values to the underlying database object.

Maybe there is a third way if not one of these two approaches?

To make the situation a bit more complicated (or maybe it doesn’t), I am rendering the form to allow for the editing of multiple rows (i.e. collection).

Thanks for any insight anybody can provide.

  • 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-13T11:29:43+00:00Added an answer on May 13, 2026 at 11:29 am

    I believe what you are looking for is the ViewModel.

    In cases where you are using a ViewModel, you design the ViewModel to match the exact data you need to show on your page.

    You then use your Controller to populate and map your data from your Model in to your ViewModel and back again.

    The Nerd Dinner ASP.NET MVC Example has some very good examples of using ViewModels.

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

Sidebar

Related Questions

Im having a little trouble setting up routes. I have a 'users' controller/model/views set
having a little architectural trouble here. In C++, we have the notion of 'friends,'
I'm having a little trouble with relative URIs I have a simple HttpListener app
I'm having a little trouble overloading methods in C#. I have two methods that
I have a small task in Flash, that I'm having a little trouble with.
I am having a little bit trouble with the following. I have multiple form
I am having a little trouble getting this to work. I have several anchor
Im having a little trouble constructing a query. I have a table with 3
Hay, I'm having a little trouble. I have the following domain over at easily.co.uk
I’m having a little Architecture problem. In my project I have a Business Logic

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.