Hide field from GridView but not DetailsView RRS feed

  • Question

  • User-515122190 posted

    I have been working with Dynamic Data recently and I am really impressed with it -- its a great start.  While working on a test project that had 15 or so tables with the average number of fields per table being aorund 25 it occured to me that it would be great if there was a way via attributes to hid a field from being displayed in the GridView while still allowing it to be shown in the Details view.  While I do realize that I can do this with custom pages, it gets tedous to do this when the number of tables and fields starts getting pretty large.

     Example of idea:

    public partial class Custom
        public object FirstName;

        public object LastName;

        // This field will be hidden from the GridView and shown in the Details view
        public object AddressLine1;

        // This field will be hidden from the GridView and shown in the Details view
        public object AddressLine2;

        public object AddressPostalCode;

        public object AddressCountry;

        // This field will be shown in the GridView but not in the Details view
        public object LastModifiedBy;


    Tuesday, September 9, 2008 9:44 PM


  • User1641955678 posted

    Question:  Any idea on how I can tell which type of view will be generated from within the FieldGenerator class?  I know I have access to the MetaTable, but I cannot seem to find anything that would indicate the type of parent ASP.NET control that will be the container.

    IAutoFieldGenerator.GenerateFields takes a Control, which is what you want to look at.  e.g. if it's a GridView, do this, if it's a DetailsView, do that, etc...


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, September 10, 2008 3:36 PM

All replies