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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:29:36+00:00 2026-05-11T22:29:36+00:00

I am wondering how to use Model Binding in a scenario where I am

  • 0

I am wondering how to use Model Binding in a scenario where I am returning information from more than one entity on a page?

I want to display a combination of fields from two separate entities, ie Customer + Address. I am using Microsoft’s DAAB and custom business entities for my model.

Any ideas?

  • 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-11T22:29:36+00:00Added an answer on May 11, 2026 at 10:29 pm

    If you are trying to bind to multiple models on postback, you should try using the Bind attribute and specifying the prefixes used for each model in your arguments. In some scenarios — where you may not be able to use separate prefixes for your model elements — you might find this easier to do with multiple TryUpdateModel and separate whitelists rather than putting the models in the parameters.

    public ActionResult Update( [Bind(Prefix="Customer")]Customer customer,
                                [Bind(Prefix="Address")]Address address )
    {
       ...
    }
    

    This would assume you have a ViewModel like:

    public class CustomerAddressModel
    {
        public Customer Customer { get; set; }
        public Address Address { get; set; }
    }
    

    and reference it like:

    <%= Html.TextBox( "Customer.Name" ) %>
    ...
    <%= Html.TextBox( "Address.Street" ) %>
    

    or, using TryUpdateModel,

    public ActionResult Update( int id )
    {
        var customer = db.Customers.Where( c => c.ID == id ).Single();
    
        var whitelist = new string[] { "name", "company", ... };
        if (TryUpdateModel( customer, whitelist ))
        {
            var addressWhitelist = new string[] { "street", "city", ... };
            if (TryUpdateModel( customer.Address, addressWhitelist ))
            {
                ...
            }
        }
    

    }

    In this case, your model might contain just the fields from the two different models that you are trying to update.

    public class CustomerAddressModel
    {
        public string Name { get; set; }
        public string Company { get; set; }
        public string Street { get; set; }
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am wondering how I could use data from a Model B while I
I'm wondering how to use functions from another script in Lua. For example, say
I use Model-View-Presentation Model in my application and I am wondering whether I need
I want to access a model attribute in Javascript. I use the following code:
I'm just wondering if someone could point out why one should use jQuery event
I'm wondering: if I have a folder strucure in my model and want to
I have a RegisterModel view model I use for my new account registration page.
I was wondering if anybody knew how to display only a few items from
For my Edit Profile page, all the items are from the User entity. Things
I am wondering when I would use c++ in managed versus unmanaged mode? 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.