Try Now
More in this section

Forums / Sitefinity SDK / Boolean field in custom module

Boolean field in custom module

2 posts, 0 answered
  1. jocelyn payneau
    jocelyn payneau avatar
    51 posts
    07 Dec 2009
    22 Feb 2011
    Link to this post

    I have a boolean property myField.

    In the insert/edit form, I placed a choicefielddefinitionelement. I create a new item, checked the checkbox and save. When I edit an item, the checkbox is not selected but in the database, the value is well saved (set to 1).

    Here is my code:
    private bool myField;
            public bool MyField
                get { return this.myField; }
                set { this.myField= value; }
    var myFieldElement = new ChoiceFieldElement(mainSection.Fields)
                    ID = "myFieldElementControl",
                    FieldType = typeof(ChoiceField),
                    DataFieldName = "MyField",
                    DisplayMode = displayMode,
                    MutuallyExclusive = false,
                    RenderChoiceAs = RenderChoicesAs.SingleCheckBox,
                    CssClass = "sfCheckBox sfFormSeparator",
                    Title = (displayMode == FieldDisplayMode.Read) ? "Active?" : string.Empty,
                    Description = "Description of myFieldElement",
                    WrapperTag = HtmlTextWriterTag.Li
                ChoiceElement item = new ChoiceElement(myFieldElement.ChoicesConfig)
                    Text = "Active?"

    Do you have any idea of what could cause this issue?

  2. Pepi
    Pepi avatar
    981 posts
    20 Oct 2016
    24 Feb 2011
    Link to this post
    Hi jocelyn payneau,

    You need to copy the specific property in the manager Copy method (this is needed for the purposes of the Content Lifecycle):

    Copy Code
    public void Copy(ProductItem source, ProductItem destination)
        destination.MyField = source.MyField;

    Let us know if this solves the described issue.

    Best wishes,
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
2 posts, 0 answered