locked
Sort DataGrid based on Foreign key RRS feed

  • Question

  • User1432255915 posted

    Hi,

    What is the easiest way to sort the Grid (not the dropdown box) in the List.aspx based on a foreign key column in the grid?

    This is the Entity

    I am using the DisplayColumn attribute to sort the dropdown boxes but it does not work for the grid.
    
    [MetadataType(typeof(UserMetaData))]
        [DisplayColumn("FirstName", "FirstName", false)]
        public partial class User
        {
            public override string ToString()
            {
                return FirstName + " " + LastName;
            }
    
            internal class UserMetaData
            {
               [DisplayName("Name")]
                public object FirstName{ get; set; }
    
                [DisplayName("Last Name")]
                public object LastName{ get; set; }
    
               
            }
           
        }
    
    Here I have the foreign key User  
    public partial class ITInventory
        {
            public class ITInventoryMetaData
            {
               
                public object Active;
                [DisplayName("Mobile No")]
                public object MobileNo { get; set; }
                [DisplayName("Users")]
                public object User { get; set; }
    
    
            }
        }

    Cheers,

     

    CP

    Monday, February 18, 2013 7:48 AM

All replies