This is a migrated thread and some comments may be shown as answers.

DataBinding: 'Telerik.Web.UI.TreeListInsertionObject' does not contain a property with the name ""

3 Answers 141 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Sayantan
Top achievements
Rank 1
Sayantan asked on 21 Dec 2012, 12:01 PM
Hi friends,I have Telerik Treelist control which works perfectly when I use EditFormType="AutoGenerated"
but when I use EditFormType="Template" with a customized template my template for insertion is not showing when I click in the Add(+) image.The template for edit works fine.
When I use breakpoint in the RadTreeList1_ChildItemsDataBind event I found this error.
I have a textbox and checkbox in the template.
The aspcheckbox is creating the problem.I tried with the following solution of using RadTreeList1_ItemCommand()
System.Collections.Specialized.ListDictionary newValues = new System.Collections.Specialized.ListDictionary();
    newValues["AccountName"] = string.empty
    newValues["IsDirect"] = true;

----------------------------------------------------------------------------------------------------------------------------------------------------------------------
but it does'nt work.
I am posting my code sniplet below:

<telerik:RadTreeList ID="RadTreeList1" runat="server"
            AutoGenerateColumns="false" DataKeyNames="AccountId"
        AllowLoadOnDemand="True"  EditMode="EditForms"
            onchilditemsdatabind="RadTreeList1_ChildItemsDataBind"
            onneeddatasource="RadTreeList1_NeedDataSource" AllowPaging="True" AllowSorting="True"           
            ParentDataKeyNames="PAccountId" Skin="Web20"
            oninsertcommand="RadTreeList1_InsertCommand"       
            >
<Columns>
               <telerik:TreeListEditCommandColumn UniqueName="InsertCommandColumn" ButtonType="ImageButton"
                HeaderStyle-Width="50px" ItemStyle-HorizontalAlign="Center">
            </telerik:TreeListEditCommandColumn>
               <telerik:TreeListButtonColumn UniqueName="DeleteCommandColumn" Text="Delete" CommandName="Delete"
                ButtonType="ImageButton" HeaderStyle-Width="20px">
            </telerik:TreeListButtonColumn>
                <telerik:TreeListBoundColumn DataField="AccountId" HeaderText="ActId" ReadOnly="true"
                    UniqueName="AccountId"  HeaderStyle-Width="30px" ForceExtractValue="Always">                    
                </telerik:TreeListBoundColumn>
                 <telerik:TreeListBoundColumn DataField="PAccountId" HeaderText="PActId" ReadOnly="true"
                    MaxWidth="" MinWidth="" UniqueName="PAccountId"  HeaderStyle-Width="30px" ForceExtractValue="Always">                    
                </telerik:TreeListBoundColumn>
                <telerik:TreeListBoundColumn DataField="AccountName" HeaderText="Account Name"  
                    HeaderStyle-Width="180px" UniqueName="ActName">
                </telerik:TreeListBoundColumn>
 </Columns>
            
            <EditFormSettings EditFormType="Template">
                <FormTemplate>
                <table class="modalBox" style="width:500px">
                 <tr>
                        <td style="height:10px"></td>
                    </tr>
                    <tr>
                        <td>
                            <table>
                                <tr>
                                <td align="left"><asp:Label ID="lblAccountName" runat="server" Text="Account Name" CssClass="Main_LabelText" Width="120px"></asp:Label>
                                </td>
                                <td align="left">
                               <asp:TextBox ID="txtAccountName" runat="server" Text='<%# Eval("AccountName") %>'   CssClass="TextBoxSmall"></asp:TextBox>
                             </td>
                                </tr>
                                <tr>
                                    <td style="height:10px"></td>
                                </tr>
                            </table>
                        </td>
                    </tr>
 <tr>
                                    <td>                                  
                                        <asp:CheckBox ID="chkIsDirect" CssClass="chkbxSmall" Width="100px" runat="server" Text="IsDirect" TextAlign="Left" Checked='<%# Bind("IsDirect") %>' />
                                        
                                    </td>
                                </tr>
                            </table>
 <tr>
                        <td>
                            <table>
                                <tr>
                                    <td style="height:10px"></td>
                                </tr>
                                <tr>
                                <td>
                               <telerik:RadButton ID="btnUpdate" Text='<%# (Container is TreeListEditFormInsertItem) ? "Insert" : "Update" %>'
                                runat="server" CommandName='<%# (Container is TreeListEditFormInsertItem) ? "PerformInsert" : "Update" %>'
                                Icon-PrimaryIconCssClass="rbOk">
                            </telerik:RadButton>
                           
                            </td>
                                <td> <telerik:RadButton ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"
                                CommandName="Cancel" Icon-PrimaryIconCssClass="rbCancel">
                            </telerik:RadButton></td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    
                    <tr>
                        <td style="height:10px"></td>
                    </tr>
                </table>
                   
                </FormTemplate>
            </EditFormSettings>
            
        </telerik:RadTreeList>

3 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 26 Dec 2012, 09:02 AM
Hello Sayantan,

Please use Bind method instead of Eval for all of the edited fields controls. For practical implementation of your scenario, please refer to this demo:
http://demos.telerik.com/aspnet-ajax/treelist/examples/dataediting/formtemplateusercontrol/defaultcs.aspx

I hope this will prove helpful.

Regards,
Eyup
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.
0
Sayantan
Top achievements
Rank 1
answered on 27 Dec 2012, 09:25 AM
Hello Eyup,
I tried with Bind method also to bind the textbox.But it showed the same error.
Please tell me how can I use databound asp:CheckBox inside the FormTemplate.


0
Khurram Nazir
Top achievements
Rank 2
answered on 21 Oct 2014, 08:20 AM
Hello Sayantan,


In order to bind the controls in FormTemplate, you have to have all those columns in <column> section. If you don't want to show them then you to set the visible property to false, then Bind works.
Tags
TreeList
Asked by
Sayantan
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Sayantan
Top achievements
Rank 1
Khurram Nazir
Top achievements
Rank 2
Share this question
or