Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Treeview > Treeview binding problem
RadControls for ASP.NET are no longer supported (see this page for reference). In case you have inquiries about the Telerik ASP.NET AJAX controls, post them in the pertinent ASP.NET AJAX forums.

Not answered Treeview binding problem

Feed from this thread
  • goldy avatar

    Posted on Apr 21, 2011 (permalink)

    Hello to all

    "This constraint cannot be enabled as not all values have corresponding parent values."

    i got this error on binding treeview by sql database

                            <asp:SqlDataSource runat="server" ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:PLOConnectionString %>"
                                SelectCommand="declare @usertype as int,@ID as int set @ID=@clientID set @usertype=@nodetype  if @usertype=1  begin select nodeid,nodehtml,parentId from (SELECT nodeid, nodehtml + ' ('+ (select case when rights= 1 then 'NULL' when rights=0 then 'Read' when rights=2 then 'Write' when rights=4 then 'Full' end a from treeviewrights where nodeid=a.nodeid and clientid=@ID and rights<>1) + ')' as nodehtml, parentId from treeview a where clientid  in (select ownerid from  clientpersonaldetails where id= @ID) and nodetype='Folder' )x where nodehtml<>'NULL' end else begin SELECT nodeid, nodehtml , parentId from treeview a where clientid = @ID end">
                                
                                <SelectParameters>
                                    <asp:CookieParameter CookieName="userid" Name="clientID" Type="Int32" />
                                    <asp:CookieParameter CookieName="usertype" Name="nodetype" Type="String" />
                                </SelectParameters>
                            </asp:SqlDataSource>


    this is my query to bind treeview.

    <telerik:RadTreeView runat="server" ID="RadTreeView1" DataSourceID="SqlDataSource1"
                                DataFieldID="nodeid" DataFieldParentID="parentId" DataTextField="nodehtml" DataValueField="nodeid"
                                OnNodeClick="RadTreeView1_NodeClick" Skin="WebBlue" OnClientContextMenuShowing="onClientContextMenuShowing"
                                OnClientContextMenuItemClicking="setAsDesktopItemClickedtree" ForeColor="White">
                                <ContextMenus>
                                    <telerik:RadTreeViewContextMenu ID="MainContextMenu" runat="server">
                                        <Items>
                                            <telerik:RadMenuItem Value="ADDFolder" Text="ADD Folder" ImageUrl="~/Img/Outlook/12.gif">
                                            </telerik:RadMenuItem>
                                            <telerik:RadMenuItem Value="Upload" Text="Upload File" ImageUrl="~/Img/Outlook/11.gif">
                                            </telerik:RadMenuItem>
                                            <telerik:RadMenuItem Value="Rename" Text="Rename" ImageUrl="~/Img/Outlook/rename.gif">
                                            </telerik:RadMenuItem>
                                            <telerik:RadMenuItem Value="Delete" Text="Delete" ImageUrl="~/Img/Outlook/7.gif">
                                            </telerik:RadMenuItem>
                                            <telerik:RadMenuItem Value="Move" Text="Move" ImageUrl="~/Img/Outlook/8.gif">
                                            </telerik:RadMenuItem>
                                            <telerik:RadMenuItem Value="View" Text="View" ImageUrl="~/Img/Outlook/9.gif">
                                            </telerik:RadMenuItem>
                                            <telerik:RadMenuItem Value="Email" Text="Email" ImageUrl="~/Img/Outlook/3.gif">
                                            </telerik:RadMenuItem>
                                              <telerik:RadMenuItem Value="Properties" Text="Properties" ImageUrl="~/Img/Outlook/18.gif">
                                            </telerik:RadMenuItem>
                                            <telerik:RadMenuItem IsSeparator="true">
                                            </telerik:RadMenuItem>
                                        </Items>
                                        <CollapseAnimation Type="none" />
                                    </telerik:RadTreeViewContextMenu>
                                </ContextMenus>
                                <DataBindings>
                                    <telerik:RadTreeNodeBinding TextField="nodehtml" />
                                    <telerik:RadTreeNodeBinding Depth="0" TextField="nodehtml" Expanded="true" CssClass="rootNode" />
                                </DataBindings>
                            </telerik:RadTreeView>

    how to over come from this problem.help me

  • Posted on May 13, 2011 (permalink)

    Hello Goldy,

    The ParentID of the root items should be null. If for some reason the data source comes without null values for the ParentID column, the solution is to create a query that returns the expected value (null).
    Please go throught he following links which refers to the above mentioned:
    Treeview Problem - This constraint cannot be enabled as not all values have corresponding parent values.

    Thanks,
    Princy.

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Treeview > Treeview binding problem