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?"
;
authorizeField.ChoicesConfig.Add(item);
Unable to cast object of type 'Telerik.Sitefinity.Web.UI.ContentUI.Config.ContentViewSectionElement' to type 'Telerik.Sitefinity.Web.UI.Fields.Config.FieldDefinitionElement'.
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,