Bound a treeview control to user-defined complex type using EF 4
Posted
by
GIbboK
on Stack Overflow
See other posts from Stack Overflow
or by GIbboK
Published on 2011-01-06T09:49:16Z
Indexed on
2011/01/06
9:54 UTC
Read the original article
Hit count: 263
Hi, I use Asp.net, SQL 2008 and EF 4.
I need display hierarchy data in a treeview control, Data is stored in a DB that use HierarchyId.
Unfortunately, EF4 doesn't support HierarchyId. So in this case, I thought to have a stored procedure that deals with my hierarchy and return a result set back to EF that EF4 can turn into a collection of user-defined complex type that can then be bound directly to the treeview control.
I imported a SPROC in EF 4 using Import Function and now I have a Complex DataType called:
CategoryHierarchy_Result
An image of my Model:
Here some data from the Complex Type (in a GridView for example GridView1.DataSource = context.CategoryHierarchy(1);):
My questions is:
- How to display my data from my Complex Type in a TreeView Control, showing a Tree structure that respect CategoryNodeString?
I am a beginner an I never use TreeView before, any help or resource would be appreciated! Thanks!.
Here some useful resource: http://www.robbagby.com/entity-framework/entity-framework-modeling-action-stored-procedures/
© Stack Overflow or respective owner