Adding a boolean field to the backend section - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

Adding a boolean field to the backend section

  • Adding a boolean field to the backend section
  • Hi all,

    I'm trying to add a field to my backend main section that should represent a checkbox (boolean field).

    This is my definition:
    var authorizeField = new ChoiceFieldElement(paymentSection)
        ID = "authorizeFieldControl",
        DataFieldName = "Authorize",
        FieldType = typeof(ChoiceField),
        RenderChoiceAs = RenderChoicesAs.SingleCheckBox,
        DisplayMode = displayMode,
        MutuallyExclusive = true,
        CssClass = "sfCheckBox",
        Title = (displayMode == FieldDisplayMode.Read) ? "Active?" : string.Empty,
        WrapperTag = HtmlTextWriterTag.Li,
        ResourceClassId = typeof(DonationsResources).Name,
    ChoiceElement item = new ChoiceElement(authorizeField.ChoicesConfig)
        Text = "Active?"

    I'm getting this error:
    Unable to cast object of type 'Telerik.Sitefinity.Web.UI.ContentUI.Config.ContentViewSectionElement' to type 'Telerik.Sitefinity.Web.UI.Fields.Config.FieldDefinitionElement'.

    What am I doing wrong?

  • Hi Daniel,

    I think the error you are getting is not related to this code. The code is fine, but probably the element, to which you add this ChoiceFieldElement is not the correct type. Can you provide more information from the stack trace or code for the rest of the fields that you add to the main section?

    All the best,
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>