Search code examples
entity-frameworkdynamic-data

ASP.NET Dynamic Data : How to Specify Sort Order of Items in Dropdown List


I am using ASP.NET dynamic data for the data adminstration tasks for a Silverlight app that I built. It saved a ton of time not having to write all of the admin screens you typically have to create for end users to manage the data.

One thing I cannot figure out how to sort the items in the drop downs that appear on the screens - either the filter dropdowns on the list views or on the data entry screens.

Do I specify that somewhere in the EDM partial classes or in the ASP.NET DD field templates? or somewhere else?

All I need to do is sort alphabetically by the display value- they appear to be in random order.

thanks Michael


Solution

  • Use the DisplayColumn Attribute in the System.ComponentModel.DataAnnotations Namespace.

    http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.displaycolumnattribute.aspx

    ex:

    [DisplayColumn("LastName", "LastName")]
    public partial class Employee
    {
    
    
    }