locked
Editing custom property/column RRS feed

  • Question

  • User923737044 posted

    In a given table I have a foreign key column called Role (the type of this column is Role, which is the name of referenced table). Because it needs to be displayed in a specific way, I have "replaced" the Role column with a custom property called RoleWithDefault (see below). I am perfectly able to display the contents of this property (by creating my own FieldTemplate) but I am not sure how to create a FieldTemplate for editing. The setter of RoleWithDefault is simply setting the Role property based on a string value to be selected by the user. Can anyone point me in the right direction?

    public class MyClass
    {
           public Role RoleWithDefault
            {
                    // some get and set
            }
    }
    
    public class MyClassMetadata
    {
    
        [ScaffoldColumn(true)]
        [DisplayName("Role")]
        public object RoleWithDefault { get; set; }
    
        [ScaffoldColumn(false)]
        public object Role { get; set; }
    
    }
    Thursday, August 18, 2011 10:01 AM

Answers

  • User923737044 posted

    Hi,

    I solved it by having two columns/properties and hiding the custom column (RoleWithDefault) when in edit/insert mode and hiding the original column (Role) when in read mode. In this way, RoleWithDefault can be used to display the column contents in a custom way, while the user selects entities from the original column when inserting/editing the parent entity. Hiding of columns is quite easy to implement: http://csharpbits.notaclue.net/2010/02/new-way-to-do-column-generation-in.html

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 22, 2011 3:26 AM

All replies

  • User3866881 posted

    The setter of RoleWithDefault is simply setting the Role property based on a string value to be selected by the user.

    Hello:)

    How to select? From a Dropdownlist Or from somewhere else, a querystring's past value?

    Thx again

    Friday, August 19, 2011 10:23 PM
  • User923737044 posted

    Hi,

    I solved it by having two columns/properties and hiding the custom column (RoleWithDefault) when in edit/insert mode and hiding the original column (Role) when in read mode. In this way, RoleWithDefault can be used to display the column contents in a custom way, while the user selects entities from the original column when inserting/editing the parent entity. Hiding of columns is quite easy to implement: http://csharpbits.notaclue.net/2010/02/new-way-to-do-column-generation-in.html

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 22, 2011 3:26 AM