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

OnClick not fired with Entity/LINQ DataSource

2 Answers 65 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Lone
Top achievements
Rank 1
Lone asked on 23 Feb 2011, 10:54 PM
Hey Telerik

I have big problems using my Entity datasource with my TreeView.
Everything is shown just fine, but can't get OnNodeClick event to fire.

Please advise !!

Thanks
Jan

<telerik:RadTreeView runat="Server" ID="BookGroupTreeView" DataFieldID="Hierarchy_id"
    DataFieldParentID="Parent_Hierarchy_id" DataTextField="Name" DataValueField="Hierarchy_id"
    Skin="Vista" EnableTheming="True" RegisterWithScriptManager="true" OnNodeClick="BookGroupTreeView_NodeClick">
</telerik:RadTreeView>

protected void Page_Load(object sender, EventArgs e)
 {
     List<DB.Hierarchy> bookHierarchy = new List<DB.Hierarchy>();
     bookHierarchy = DB.HierarchyService.HierarchyFullListFromParentPath("Root");
 
     BookGroupTreeView.DataSource = bookHierarchy;
     BookGroupTreeView.DataBind();
     BookGroupTreeView.ExpandAllNodes();
 }

2 Answers, 1 is accepted

Sort by
0
Kate
Telerik team
answered on 25 Feb 2011, 03:48 PM
Hi Jan Hjørdie,

Here is a sample page with two treeview controls - one linked to an entity datasource, the other one linked to a linq datasource. I attached an event handler on both trees and it behaves as it should - the event is fired.

Best wishes,
Kate
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Lone
Top achievements
Rank 1
answered on 25 Feb 2011, 04:44 PM
Hey Kate
Thanks for your example.
My data is not presentet the way you suggest. I have my data layer in a seperate project. My DB project, where I ex. have a Hierachy Service, that return a List<Hierachy>.

So what should I do then ? Do I need the LinqDataSource ? I just thought setting the treeview datasource to bookHierachy was enough ?
My treeview is rendered just fine, it's just my OnNodeClick event that don't fire ?

 <asp:LinqDataSource ID="LinqDataSource1" runat="server" EntityTypeName="" ContextTypeName="DataClassesDataContext"

           TableName="Links">

 </asp:LinqDataSource>


List<DB.Hierarchy> bookHierarchy = new List<DB.Hierarchy>();

bookHierarchy = DB.HierarchyService.HierarchyFullListFromParentPath("Emner");

 
Thanks
Jan
Tags
TreeView
Asked by
Lone
Top achievements
Rank 1
Answers by
Kate
Telerik team
Lone
Top achievements
Rank 1
Share this question
or