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

Parent Columns and Child Columns don't have matching columns

4 Answers 754 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Adela
Top achievements
Rank 1
Adela asked on 07 Nov 2014, 10:28 PM
Hi,

I'm trying to use programmatic data binding, as in this demo http://demos.telerik.com/aspnet-ajax/treeview/examples/programming/databinding/defaultcs.aspx
But I'm getting the message error: 

Parent Columns and Child Columns don't have matching columns (my SO is in spanish, so the original message is "Las columnas primarias y las columnas secundarias no tienen columnas que coincidan.")

Attached is an image of my data and this is my code:

    System.Data.DataSet ds = st.getFileStructure();

     treeView.DataTextField = "leafDisplayName";
     treeView.DataFieldID = "leafName";
     treeView.DataFieldParentID = "Parent";
 
     treeView.DataSource = ds;
     treeView.DataBind();

and this is my stack trace:  

[InvalidConstraintException: Las columnas primarias y las columnas secundarias no tienen columnas que coincidan.]
POsWorkflow.UserControls.FileStructureCtrl.BindToDataSet(RadTreeView treeView, Boolean isGidStructure) in C:\Users\...\UserControls\FileStructureCtrl.ascx.cs:217
POsWorkflow.UserControls.FileStructureCtrl.Page_Load(Object sender, EventArgs e) in C:\Users\...\UserControls\FileStructureCtrl.ascx.cs:65
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
System.Web.UI.Control.OnLoad(EventArgs e) +92
System.Web.UI.Control.LoadRecursive() +54
System.Web.UI.Control.LoadRecursive() +145
System.Web.UI.Control.LoadRecursive() +145
System.Web.UI.Control.LoadRecursive() +145
System.Web.UI.Control.LoadRecursive() +145
System.Web.UI.Control.LoadRecursive() +145
System.Web.UI.Control.LoadRecursive() +145
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772


I don´t know what i'm doing wrong. Some body help :(

Thanks in advance.



4 Answers, 1 is accepted

Sort by
0
Bozhidar
Telerik team
answered on 11 Nov 2014, 07:29 AM
Hi,

Could you specify whether the two columns in your SQL table have the same data type?

Regards,
Bozhidar
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Adela
Top achievements
Rank 1
answered on 11 Nov 2014, 02:26 PM
 [quote]Bozhidar said:Hi,

Could you specify whether the two columns in your SQL table have the same data type?

Regards,
Bozhidar
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
[/quote]

Hi Bozhidar,

Attached is an image showing the result set that I'm using, Parent and child columns are int type. 
I'm also trying with declarative binding, but I get the same message error.

1.<telerik:RadTreeView ID="treeSupplier" runat="server" DataFieldID="leafName"
2.     DataFieldParentID="Parent" DataSourceID="SqlDataSource1">
3.     <DataBindings>
4.         <telerik:RadTreeNodeBinding TextField="leafDisplayName" />
5.         <telerik:RadTreeNodeBinding Depth="0" TextField="leafDisplayName" />
6.     </DataBindings>
7. </telerik:RadTreeView>

I realized that when the datasource only contains two hierarchy levels (I refer to row 1 to 11 in the attached image) the treeview shows perfectly, but when the datasource includes also rows 12-14 I get the error.
:(

0
Adela
Top achievements
Rank 1
answered on 11 Nov 2014, 09:13 PM
Solved!

My stored procedure makes a Union between two tables (folders and documents). I guess the problem was the size of the columns is different. My solution was:
select
         convert(int,leafName) leafName
        , convert(varchar(255),leafDisplayName) leafDisplayName
-- etc
from (
-- union
)t

Thanks anyway!
0
Gilberto
Top achievements
Rank 1
Veteran
answered on 13 Apr 2020, 08:59 PM
Tu respuesta continúa ayudando personas 6 años después.... Gracias!!!!
Tags
TreeView
Asked by
Adela
Top achievements
Rank 1
Answers by
Bozhidar
Telerik team
Adela
Top achievements
Rank 1
Gilberto
Top achievements
Rank 1
Veteran
Share this question
or