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

RadTreeView Error When Parent Null

3 Answers 132 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 13 Jan 2014, 06:34 PM
Hi all,

I have a SQL Data Source with three columns for simplicity (Organization_Name, Organization_ID, Organization_Parent_ID).

I am receiving the following error, "This constraint cannot be enabled as not all values have corresponding parent values."  This makes sense as some of the Organization_Parent_ID values are null.  How can I circumvent this error message, showing all of the parent organizations with their children underneath?

It should look something like this:

Organization_A
Organization_B
Organization_C
Organization_D
          Sub_Organization_A
          Sub_Organization_B
Organization_E

I see in the Object Data Source example in this link that there are multiple root level items as well.

Thanks,
Mark




3 Answers, 1 is accepted

Sort by
0
Mark
Top achievements
Rank 1
answered on 15 Jan 2014, 09:08 PM
Anyone . . . ?
0
Princy
Top achievements
Rank 2
answered on 16 Jan 2014, 04:13 AM
Hi Mark,

Unfortunately I couldn't replicate the issue at my end. Please have a look into the sample code snippet I tried with SqlDataSource which works fine at my end.

ASPX:
<telerik:RadTreeView ID="RadTreeView1" runat="server" DataFieldID="Organization_ID" DataFieldParentID="Organization_Parent_ID"
    DataSourceID="SqlDataSource1" DataTextField="Organization_Name">
</telerik:RadTreeView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Northwind_newConnectionString %>"
    SelectCommand="SELECT [Organization_Name], [Organization_ID], [Organization_Parent_ID] FROM [Organization]">
</asp:SqlDataSource>

Thanks,
Princy.
0
Mark
Top achievements
Rank 1
answered on 16 Jan 2014, 09:26 PM
Princy,

Thank you very much for the reply!

Unfortunately, my solution is entirely in code-behind as part of a SharePoint Web Part.  It looks very similar to yours.  The RadTreeView and SQLDataSource are added in CreateChildControls.  Any thoughts?

Thanks,
Mark
Tags
TreeView
Asked by
Mark
Top achievements
Rank 1
Answers by
Mark
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or