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

This constraint cannot be enabled

4 Answers 246 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Mohamed
Top achievements
Rank 1
Mohamed asked on 23 Apr 2008, 10:25 AM

Hi all
i have class that return datatable when i bind to treeview i got this error
This constraint cannot be enabled as not all values have corresponding parent values

and this is stack

ArgumentException: This constraint cannot be enabled as not all values have corresponding parent values.]
   System.Data.ConstraintCollection.Add(Constraint constraint, Boolean addUniqueWhenAddingForeign) +502
   System.Data.DataSetRelationCollection.AddCore(DataRelation relation) +1069
   System.Data.DataRelationCollection.Add(DataRelation relation) +138
   System.Data.DataRelationCollection.Add(DataColumn parentColumn, DataColumn childColumn) +43
   Telerik.Web.UI.ControlDataBinder.BindToDataTable(DataTable data, String dataFieldID, String dataFieldParentID) +150
   Telerik.Web.UI.HierarchicalControlItemContainer.PerformDataBinding(IEnumerable data) +447
   System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +111
   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +29
   System.Web.UI.WebControls.DataBoundControl.PerformSelect() +149
   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +70
   BNIS.FundMarket.Web.GL.ChartOfAccount.Page_Load(Object sender, EventArgs e) in C:\Projects\FundMarket\BNIS.FundMarket.Web\GL\ChartOfAccount.aspx.cs:31
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +33
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +47
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436


and this is cod from page load

DataTable

dt = BL.GL.mm();

tvChartOfAccount.DataSource = dt;

tvChartOfAccount.DataFieldID = dt.Columns[

"AccountNo"].ColumnName;

tvChartOfAccount.DataFieldParentID = dt.Columns[

"ParentAccountNo"].ColumnName;

tvChartOfAccount.DataTextField = dt.Columns[

"ENAccountName"].ColumnName;

tvChartOfAccount.DataBind();



what is that error ?

4 Answers, 1 is accepted

Sort by
0
Accepted
Veselin Vasilev
Telerik team
answered on 23 Apr 2008, 10:39 AM
Hello Mohamed,

Can you check if the root nodes have null values in their ParentAccountNo column?
They have to be null.

Sincerely yours,
Veskoni
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Mohamed
Top achievements
Rank 1
answered on 23 Apr 2008, 10:53 AM
Hi Veskoni

i put root with null and it works
Thanks alot
0
Veselin Vasilev
Telerik team
answered on 25 Jul 2008, 06:58 AM
Hello Jim Black,

Yes, this is a requirement for the DataFieldID / DataFieldParentID to work.

If you cannot afford this then you can manually load your nodes to a DataTable and create the RadTreeViewNode objects. 

Sincerely yours,
Veskoni
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
TreeView
Asked by
Mohamed
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Mohamed
Top achievements
Rank 1
Jim Black
Top achievements
Rank 1
Share this question
or