I have seen other similar questions dealing with WPF Almost exactly the same but I can;t figure this out in ASP.net. I have a Pages table with a parentpage foreign key and want to databind them to a treeview. In the past I have created a hierarchicaldataset from a dataset but would like to stay within the entities framework if I can. Thanks!
The ASP.NET TreeView and the WPF TreeView controls are to very, very different beasts.
The fact that WPF generally supports data binding for hierarchical data-sets out-of-the-box is what makes it so easy.
In the end the data-binding mechanisms are radically different so comparing them would be an apples-to-oranges comparison.
As to how you would actually perform the data binding using LINQ-to-Entities, the data binding model for the TreeView in ASP.NET allows you to bind to an XML file, but you have to define the depth of the tree in the declaration of the control, something that I feel you don't know beforehand.
The only benefit that I see that the Entity framework could give you here is the possiblity of generating an anonymous type (projection) which is hierarchical in nature. However, I don't really see the gain here because in the end, you will have to populate the tree control manually, and a hierarchical structure doesn't give you any inherent benefits over the flat one you have now in the form of the table, assuming you return your records in the proper order so that when you traverse in a forward manner, you are performing the "tree" traversal the same way as if you did it recurively with a true object tree.