locked
customizing display data RRS feed

  • Question

  • User-1233944992 posted

    I created a dynamic data web site (tried using both options in vs, web site or web application), and at first everything works. but when i try to customize appearance (not display all columns and stuff like that) nothing happens.

    Not sure what I'm missing: create a partial class that has the same name as the table (using Linq to sql, tried naming the class exactly like the table, and ading s on the end as thats what datacontext usually generates), create another metadata class, put the attribute in the first class that references the metadata class, and then make public properties in the metadata class. What am I missing?
    Thanx for help :)

    ...
    using System.Web.DynamicData;
    using System.ComponentModel.DataAnnotations;

    [MetadataType(typeof(Metaclass_Metadata))]
    public partial class TableName
    {
    }

    public partial class Metaclass_Metadata
    {
        public object ID;

        [UIHint("DisplayCaption")]
        public object AnotherColumn;
    }

    Thursday, August 28, 2008 8:23 AM

All replies

  • User188291263 posted

     Make sure to register context,usually in global.asax put code something like

    model.RegisterContext(typeof(eStoreDataContext), new ContextConfiguration() { ScaffoldAllTables = true });
    On your metadata you need to have getter or/and setter

     In your metadata class,when you use UIHint you specify your custom control. Are you using custom control,or if you want just show "Display Caption"

    then use 

    [DisplayName("Metaclass")]
     public partial class Metaclass_Metadata
    {
        [ScaffoldColumn(false)]
        public object ID{ get; set; };

       [DisplayName("Display Caption")]
        public object AnotherColumn{ get; set; };
    }

    Thursday, August 28, 2008 10:32 AM
  • User933528419 posted

    Make sure your partial class name is the same as in the designer generated class. Usually the partial class does not contain the s in the end.

    I hope this helps.

    Maíra

    Thursday, August 28, 2008 12:36 PM