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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:12:41+00:00 2026-06-07T13:12:41+00:00

I am curious how to do the following. I have a main view with

  • 0

I am curious how to do the following. I have a main view with parent data about support cases. I also will be showing a child list of MTM data using a partial view. I have built a ViewModel to supply the partial view with the data needed.

Here is my ViewModel:

public class CaseComplaintsViewModel
    {
    public string ComplaintCode { get; set; }
    public string ComplaintType { get; set; }
    }

The ViewModel is based on data from these two domain models:

public class CaseComplaint
    {
    [Key]
    public int CaseComplaintID { get; set; }
    public int CasesID { get; set; }
    public int ComplaintCodeID { get; set; }
    public virtual Cases Cases { get; set; }
    public virtual ComplaintCode ComplaintCode { get; set; }
    }

public class ComplaintCode
        {
        public int ComplaintCodeID { get; set; }

        [MaxLength(50)]
        [Required(ErrorMessage="Complaint Code is required")]
        public string ComplaintCodeName { get; set; }

        [MaxLength(50)]
        [Required(ErrorMessage="Complaint Type is required")]
        public string ComplaintType { get; set; }

        public virtual ICollection<CaseComplaint> CaseComplaint { get; set; }

        }

Pretty simple.

Here is the partial view.

@model IEnumerable<cummins_db.ViewModels.CaseComplaintsViewModel>

<table width="100%">
<tr>
<th>Complaint Code</th>
<th>Complaint Description</th>
</tr>  
@foreach (var item in Model)
    {
<tr>
    <td>
        @Html.DisplayFor(modelItem => item.ComplaintCode )    
    </td>
    <td>
        @Html.DisplayFor(modelItem => item.ComplaintType)
    </td>

</tr>
    }
</table>

This partial view will be used inside of my main Cases view. I will also periodically refresh this partial view using ajax.

So my questions is, how do I get the correct data into the view when my main cases view opens? Does the partial view need it’s own controller or do I handle that in the Cases controller?

  • 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-06-07T13:12:42+00:00Added an answer on June 7, 2026 at 1:12 pm

    Yes, it needs his own Action were you handle the data send it to the client. For example

    public ActionResult ShowCaseComplaints(int someID)
    {
        //creates a linq or database sql could something like
        /*var data = db.Complains.Find(someID).Select( x => new CaseComplaintsViewModel(){
            ComplaintCode = x.ComplaintCode,
            ComplaintType = x.ComplaintType
        }).ToList();*/
    
        var data = (from C in db.CaseComplaint 
                    where C.CaseID == someID
                    select C.ComplaintCode).ToList().Select( x => new CaseComplaintsViewModel(){
                         ComplaintCode = x.ComplaintCode,
                         ComplaintType = x.ComplaintType
                    }).ToList();
        return PartialView("Your_Partial_View_Name", data);
    }
    

    Notes that i’m assuming you have a base class from where you are creating the ViewModel.

    To render the partial from your main view you just called in main view like this assuming that you main view it’s strongly typed for

    @model CaseComplaint
    
    <div id="complaintlist">
        @Html.Action("ShowCaseComplaints","yourController", new { someID = model.CaseID}
    </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just curious what is the best practice for solving the following issue. I have
Curious about running multiple xvfb displays: I have between 10-50 instances of a script
I have the following YAML: - name: List of monkeys - author: Nicolas Raoul
i have encountered the following curious piece of code: function foo(){ works = {hello:world};
So I have the following test code: #include <string.h> #include <stdio.h> int main(int argc,
I have the following HTML: <div id=main> <a id=sub1>sub1</div> <a id=sub2>sub2</div> </div> <div id=other
I have the following: @books.each do |book| ... stuff end I'm curious to learn.
I have the following if, else if, else construct and I am just curious
I'm curious if following code would be considered safe? using (SqlConnection cn = new
The following code works, but I'm curious as to why I need the Path

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.