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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:33:54+00:00 2026-05-25T02:33:54+00:00

I have a model like this: public class MyModel { [ScaffoldColumn(false)] public int CharityId

  • 0

I have a model like this:

public class MyModel {
    [ScaffoldColumn(false)]
    public int CharityId { get; set; }

    [UIHint("Charities")]
    public SelectList Charities { get; set; }
}

Then I have an EditorTemplate called Charities.cshtml:

@model MyModel

@Html.DropDownListFor(model => model.CharityId, Model.Charities)

Then in my page:

@model MyModel

@Html.EditorForModel()

However, no matter what, it doesn’t render the Charities template. I’ve been wracking my brain on this, and it should work.. but it’s not.

Any ideas?

EDIT:

The issue is that the default Object template will not render a complex object other than itself (so called shallow dive), even if there is a UIHint. I was under the impression that a UIHint would make it render the template, but I was apparently wrong.

The fix is to not try to let the model render itself. That is sad.

  • 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-25T02:33:54+00:00Added an answer on May 25, 2026 at 2:33 am

    First things first @EditoFormodel() in your page looks bizarre. I guess you meant something else.

    Now to the point: you have decorated the Charities property with UIHint. This property is of type SelectList. This means that the Charities.cshtml template should be strongly typed to SelectList, not to MyModel as you did. You could simply remove this UIHint attribute and have the following view model:

    public class MyModel {
        [ScaffoldColumn(false)]
        public int CharityId { get; set; }
    
        public SelectList Charities { get; set; }
    }
    

    and in your view:

    @model MyModel
    @Html.EditorForModel()
    

    and then inside ~/Views/Shared/EditorTemplates/MyModel.cshtml have:

    @model MyModel
    @Html.DropDownListFor(model => model.CharityId, Model.Charities)
    

    That’s the standard conventions. If you want your editor template to be called Charities.cshtml you could do this in your page:

    @model MyModel
    @Html.EditorForModel("Charities")
    

    But usually you would have the following model:

    public class FooViewModel
    {
        [UIHint("Charities")]
        public MyModel Charities { get; set; }
    }
    

    Now if your main view is strongly typed to FooViewModel you can:

    @model FooViewModel
    @Html.EditorFor(x => x.Charities)
    

    which will render the Charities.cshtml editor template.

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

Sidebar

Related Questions

My model is something like this: public class Line { public int CatalogNumber {get;
I have a field in my model class like below: [ScaffoldColumn(false)] public DateTime DatePosted
Given I have a Model object like ... public class MyModel { public int
I have a class like this: class MyClass{ public: MyClass(int Mode); private: std::map <
Well i have a complex form view model like this : public class TransactionFormViewModel
I have a form using this model: public class MyModel { public User SalesManager
I have a model that looks something like this: public class SampleModel { public
How does the Model work? I have a Registry Class like this: public class
I have entity model like this (using EclipseLink and JPA 2.0): @Entity class A
Let's say I have a model like this class Foo(db.Model): id = db.StringProperty() bar

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.