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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:07:22+00:00 2026-05-25T16:07:22+00:00

In the MVC 3 View I want to display a single Contract and a

  • 0

In the MVC 3 View I want to display a single Contract and a list of Claims, the user will be able to create a new claim. I have created a different view for Contract and Claims how can I merge these so that there is only one view.


Darin,

How do I pass an instance of MyViewModel as the view is looking for two strings?

public ActionResult Details(int id)
{
   MyViewModel myView = new MyViewModel ();
   return View(_repository.GetContract(id), myView); 
}

Thanks


I was using PartialViews Html but I don’t see how to pass the model as a parameter.

Contract View
@model Portal.Models.Contracts
@using Portal.Models

Display data.

<div>
    @{
      Html.RenderPartial("_Claim", Portal.Models.Contracts); 

    }
</div>

I am getting an error CS0119: ‘Models.Contracts’ is a ‘type’, which is not valid in the given context.

The data is bound to the Contract View here

public ActionResult Details(int id)
{
    return View(_repository.GetContract(id);
}

How is the data bound to the PartialView _Claim which is of type IEnumerable<Models.Claims> ?

  • 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-25T16:07:22+00:00Added an answer on May 25, 2026 at 4:07 pm

    You could define a view model which will wrap those two models:

    public class MyViewModel
    {
        public Contract Contract { get; set; }
        public Claim[] Claims { get; set; }
    }
    

    then have your controller action pass an instance of MyViewModel to the view and inside this view use display templates:

    @model MyViewModel
    
    @Html.DisplayFor(x => x.Contract)
    @Html.DisplayFor(x => x.Claims)
    

    and then define display templates for the Contract and Claim models (~/Views/Shared/DisplayTemplates/Contract.cshtml and ~/Views/Shared/DisplayTemplates/Claim.cshtml).

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

Sidebar

Related Questions

I have an ASP.NET MVC application that is using a single view to display
i have just started playing aorund with asp.net mvc and i want to view
I am using MVC 4 with Razor view engine. I want to display a
I have to print/display the values of few variables in a MVC view. How
I have setup ELMAH in my MVC application and I want to display a
Currently in MVC, we have to define columns manually whenever we want to list
I have an asp mvc 2 app lication where I want to display a
I want to display a property as read only on a MVC view, and
In my Application_Error event handler i want to render an MVC-View for 404. I
I have two classes (MVC view model) which inherits from one abstract base class.

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.