How to set order of appearance for fields when using Html.EditorFor in MVC 2?

Posted by Anrie on Stack Overflow See other posts from Stack Overflow or by Anrie
Published on 2010-03-09T18:12:26Z Indexed on 2010/04/03 7:03 UTC
Read the original article Hit count: 234

Filed under:
|
|
|

I have the following classes in my Model:

public abstract class Entity : IEntity
{
    [ScaffoldColumn(false)]
    public int Id { get; set; }
    [Required,StringLength(500)]
    public string Name { get; set; }
}

and

public class Model : SortableEntity
{
    [Required]
    public ModelType Type { get; set; }
    [ListRequired]
    public List<Producer> Producers { get; set; }
    public List<PrintArea> PrintAreas { get; set; }
    public List<Color> Colors { get; set; }
}

To display the "Model" class in the view I simply call Html.EditorFor(model=>model), but the "Name" property of the base class is rendered last, which is not the desired behaviour.

Is it possible to influenece on the order of displayed fields somehow?

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET