More in this section
Forums / Sitefinity SDK / Adding a boolean field to the backend section

Adding a boolean field to the backend section

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
2 posts, 0 answered
  1. Daniel Plomp
    Daniel Plomp avatar
    952 posts
    18 Feb 2004
    20 Dec 2011
    Link to this post
    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?

  2. Slavo
    Slavo avatar
    295 posts
    24 Sep 2012
    22 Dec 2011
    Link to this post
    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 >>

2 posts, 0 answered