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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:43:06+00:00 2026-06-05T17:43:06+00:00

I have a Supplier Entitiy that contains ID – int Status – string Name

  • 0

I have a Supplier Entitiy that contains

ID - int
Status - string
Name - string
CreateDate- datetime

I am using the partial class method to create Data Annotations for the above Entity.as described here

namespace TemplateEx.Models
{
    [MetadataType(typeof(SupplierMetadata))]
    public partial class Supplier
    {
        // Note this class has nothing in it.  It's just here to add the class-level attribute.
    }

    public class SupplierMetadata
    {
        // Name the field the same as EF named the property - "FirstName" for example.
        // Also, the type needs to match.  Basically just redeclare it.
        // Note that this is a field.  I think it can be a property too, but fields definitely should work.

        [Required]
        [Display(Name = "Supplier Name")]
        public string Name;
    }
}

My defined a controller action as below

 public ViewResult Details(int id)
    {
        Supplier supplier = db.Suppliers1.Single(s => s.ID == id);
        return View(supplier);
    }

When I create a view for this action and picked the Details scaffolding for the Supplier entity following is what I got as a view

@model TemplateEx.Models.Supplier

@{
    ViewBag.Title = "Details";
}

<h2>Details</h2>

<fieldset>
    <legend>Supplier</legend>

    <div class="display-label">CreateDate</div>
    <div class="display-field">
        @Html.DisplayFor(model => model.CreateDate)
    </div>

    <div class="display-label">Status</div>
    <div class="display-field">
        @Html.DisplayFor(model => model.Status)
    </div>

    <div class="display-label">Name</div>
    <div class="display-field">
        @Html.DisplayFor(model => model.Name)
    </div>
</fieldset>
<p>
    @Html.ActionLink("Edit", "Edit", new { id=Model.ID }) |
    @Html.ActionLink("Back to List", "Index")
</p>

Notice how the model.Name has a “Name” label instead of “Supplier Name”.What am I doing wrong?

  • 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-05T17:43:07+00:00Added an answer on June 5, 2026 at 5:43 pm

    replace

    <div class="display-label">Name</div>
    

    with

    <div class="display-label">@Html.LabelFor(model => model.Name)</div>
    

    Edit :

    For the second question, look here
    How can i enforce the scaffolding automatically generated code to display the Label and the EditorFor text field at the same line in my asp.net mvc 3 (specially last answer)

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

Sidebar

Related Questions

I have a Supplier Entitiy that contains ID - int Status - string Name
I have a supplier that wants a sitemap that contains much more meta data
I have the following code: class Orders{ /** * * @var Supplier */ private
We have a product that uses a Reference from a 3rd party supplier. With
I have a method that counts the number of Contacts each Supplier, Customer and
I Supplier class: public class Supplier { .... .... .... } I have also
I am trying to create form that contains another model in rails. I have
I have an MVC3 project that is using an EF4 project as its Domain.
I have a method that receives a category id, followed by two optional string
I have suppliers table with id int value for each supplier. I'm trying to

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.