FormTemplate: checkbox (boolean) DataBinding

2 posts, 0 answers
  1. Lukasz Kalbarczyk
    Lukasz Kalbarczyk avatar
    24 posts
    Member since:
    Feb 2010

    Posted 15 Jan 2012 Link to this post

    Inside my FormTemplate I have:

    <asp:CheckBox ID="WidocznaCheckBox" runat="server" Text="Pokazuj w drzewie" CssClass="cbx" Checked='<%#Bind("Widoczna") %>'></asp:CheckBox>

    But when I'm trying to add a new record to the RadTreeList, "Specified Cast Is not Valid" is thrown.

    Using RadGrid It was possibile to write a small code-snippet:

    if ((e.CommandName == RadGrid.InitInsertCommandName))
        e.Canceled = true;
        //Prepare an IDictionary with the predefined values 
        ListDictionary newValues = new ListDictionary();
        //set initial checked state for the checkbox on init insert 
        newValues["Widoczna"] = true
        //Insert the item and rebind 

    Is there for RatTreeList any similar or equivalent snippet?

    Or any other solution?
  2. Tsvetina
    Tsvetina avatar
    2102 posts

    Posted 18 Jan 2012 Link to this post

    Hello Lukasz,

    You could try using the DefaultInsertValue property of the TreeListCheckBox column:
    <telerik:RadTreeList ID="RadTreeList1" runat="server" DataKeyNames="ID" ParentDataKeyNames="ParentID"
            <telerik:TreeListCheckBoxColumn DefaultInsertValue="true" UniqueName="CheckBoxColumn"
        <EditFormSettings EditFormType="Template">
                <asp:CheckBox ID="chk" runat="server" Checked='<%#Bind("IsChecked") %>' />

    With the above declaration, the RadTreeList control renders its form template without exceptions.

    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Back to Top