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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:54:24+00:00 2026-05-28T03:54:24+00:00

I have the following model: namespace Storage.Models { public class AdminDetail { public string

  • 0

I have the following model:

namespace Storage.Models
{
    public class AdminDetail
    {
        public string PartitionKey { get; set; }
        public string RowKey { get; set; }
        public string Title { get; set; }
        public string Status { get; set; }
        public string Type { get; set; }
        public string Level { get; set; }

        public string Order { get; set; }
        public int Row { get; set; }
    }

I have the following code in my view:

@model IList<AdminDetail>

<table>
    <thead>
        <tr>
            <th>@Html.LabelFor(x => x[0].Order)</th>
            <th>@Html.LabelFor(x => x[0].Order)</th>
            <th>@Html.LabelFor(x => x[0].Level)</th>
            <th>@Html.LabelFor(x => x[0].Title)</th>
            <th>@Html.LabelFor(x => x[0].Status)</th>
        </tr>
    </thead>
    <tbody>
    @foreach (var item in Model)
    {
        @Html.DisplayFor(model => item)
    }
    </tbody>
</table> 

And in the file: Views\DisplayTemplates\AdminDetail.cshtml

    @model AdminDetail


xxxxxxxxxxxxxxxxxxxxxxxx
<tr>
    <td>@Html.DisplayFor(x => x.Order)</td>
    <td>@Html.DisplayFor(x => x.Level)</td>
    <td class="indent_@(adminDetail.Level)">@Html.DisplayFor(x => x.Title)</td>
    <td>@Html.DisplayFor(x => x.Status)</td>
    <td>@Html.ActionLink("Edit", "Edit", 
            new { pk = adminDetail.PartitionKey, rk = adminDetail.RowKey },
            new { @class = "editLink" } )</td>    
    <td>@Ajax.ActionLink("Delete", "Delete", "Menus",
            new { pk = adminDetail.PartitionKey, rk = adminDetail.RowKey },
            new AjaxOptions {
                        HttpMethod = "POST",
                        Confirm = "Are you sure you want to delete menu item ",
                        OnSuccess = "deleteConfirmation"
                    })</td>  
    <td>@Html.DisplayFor(x => x.PartitionKey) @Html.DisplayFor(x => x.RowKey)</td>
</tr>

When my view appears I see the data for the AdminDetails records but there is no formatting for <tr> and <td> I also don’t see any x’s. I am using areas and the code for the view is inside an area. Is it possible that my code is not getting the DisplayTemplate because I am using areas?

Here’s an example of the way data appears:

<table>
    <thead>
        <tr>
            <th><label for="">Order</label></th>
            <th><label for="">Order</label></th>

            <th><label for="">Level</label></th>
            <th><label for="">Title</label></th>
            <th><label for="">Status</label></th>
        </tr>
    </thead>
    <tbody>
<div class="display-label">PartitionKey</div>
<div class="display-field">01</div>
<div class="display-label">RowKey</div>
<div class="display-field">02</div>
<div class="display-label">Title</div>
<div class="display-field">Test55</div>
<div class="display-label">Status</div>
<div class="display-field">New</div>
<div class="display-label">Type</div>
<div class="display-field"></div>
<div class="display-label">Level</div>
<div class="display-field"></div>
  • 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-28T03:54:25+00:00Added an answer on May 28, 2026 at 3:54 am

    The path to your display template is wrong. Instead of:

    Views\DisplayTemplates\AdminDetail.cshtml
    

    you should use:

    Views\Shared\DisplayTemplates\AdminDetail.cshtml
    

    Notice the Shared bit. It could also be:

    Views\XXX\DisplayTemplates\AdminDetail.cshtml
    

    where XXX is the name of the current controller if you want this display template to be available only for this controller.

    Also replace your loop:

    @foreach (var item in Model)
    {
        @Html.DisplayFor(model => item)
    }
    

    with its equivalent:

    @Html.DisplayForModel()
    

    You don’t need to loop. Since your model is a collection, ASP.NET MVC will automatically invoke your display template for each element of this collection.

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

Sidebar

Related Questions

I have the following class: namespace Storage.Models { public class AdminDetail { public string
I have the following models: WeatherForecast: namespace TravelAssistant.Model.HelperModels.Weather public class WeatherForecast:EntityBase<int> { public IList<DayForecast>
I have the following types and classes: namespace MVC.Models public class Page { public
I have a simple model namespace StackOverflow.Models { public class Test { public Test()
I have the following classes: public class Note { public string Text { get;
I have a following model: class Car(models.Model): make = models.CharField(max_length=40) mileage_limit = models.IntegerField() mileage
I have the following Model pattern: public abstract class PARENTCLASS {...} public class CHILD_A_CLASS
I have the following model structure: class Container(models.Model): pass class Generic(models.Model): name = models.CharacterField(unique=True)
I have the following model and instance: class Bashable(models.Model): name = models.CharField(max_length=100) >>> foo
I have the following model: class User: name = models.CharField( max_length = 200 )

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.