Welcome Guest Search | Active Topics | Sign In | Register

TreeView and Dataset Options
exorgroup
Posted: Monday, December 24, 2007 4:13:42 PM
Rank: Member
Groups: Member

Joined: 12/18/2007
Posts: 20
I have added a treeview with data being loaded from a database - this works fine

Now I would like to know how I can load the data in a detailsview for the node the user has clicked.

A small example - the tree will contain the name of the web pages in the CMS - when the user click on a node the web page data should be loaded in a detailsview for viewing and editing

Any comments appreciated
eo_support
Posted: Monday, December 24, 2007 6:28:59 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,083
Hi,

I am not exactly sure about your situation, but two common ways of using the TreeView is:

1. Populate NavigateUrl based on your data source. For example, Node1's NavigateUrl is "showDetail.aspx?id=1", node2's NavigateUrl is "showDetails.aspx?id=2";

2. Rely on the TreeView's ItemClick event and perform whatever operation you'd like to do on the server side;

Regardless which way you use, the key is to populate the key information (for example, "id=1", "id=2", etc) into the appropriate field. You can use DataBinding object as described in the help file, or handle ItemDataBound event and set the appropriate TreeNode property based on your data source.

Thanks

exorgroup
Posted: Tuesday, December 25, 2007 1:36:14 PM
Rank: Member
Groups: Member

Joined: 12/18/2007
Posts: 20
The item click event seems not to respond

here is the the code which is populating the tree

Dim Conn As New System.Data.SqlClient.SqlConnection
Conn.ConnectionString = ConfigurationManager.ConnectionStrings("ConnectionString").ToString
Dim SQLCMd As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand("SELECT PageID, PageParent, PageName from WebPages ORDER BY PageParent, PageSequence, PageName", Conn)
Dim da As New System.Data.SqlClient.SqlDataAdapter
da.SelectCommand = SQLCMd
Dim ds As New System.Data.DataSet
da.Fill(ds, "WebPages")
Conn.Close()

Dim parentColumn As DataColumn = ds.Tables("Webpages").Columns("PageParent")
Dim pageColumn As DataColumn = ds.Tables("Webpages").Columns("PageID")

Dim r As DataRelation = ds.Relations.Add(pageColumn, parentColumn)
r.Nested = True

Me.tvSingleExpand.DataSource = ds

Dim binding As New EO.Web.DataBinding()
binding.DataField = "PageName"
binding.Property = "Text-Html"
Me.tvSingleExpand.Bindings.Add(binding)

Me.tvSingleExpand.DataBind()

I am using the control in asp.net 2 with AJAX

Comments appreciated
eo_support
Posted: Tuesday, December 25, 2007 3:14:16 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,083
Hi,

You need to set the TreeView's RaisesServerEvent to true in order to have ItemClick event.

Thanks
exorgroup
Posted: Wednesday, December 26, 2007 4:53:05 AM
Rank: Member
Groups: Member

Joined: 12/18/2007
Posts: 20
Hi,
Thanks for the tip - it worked - now the event is raised on the server side

Now how do I populate the key information.

Comments appreciated
eo_support
Posted: Wednesday, December 26, 2007 6:00:52 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,083
Hi,

You can populate the key information (might be "PageID" field?) into each item's Value property using a DataBinding object the same way as you populate PageName into Text-Html.

Thanks
exorgroup
Posted: Tuesday, January 1, 2008 5:10:39 AM
Rank: Member
Groups: Member

Joined: 12/18/2007
Posts: 20
Hi,
Thanks for the suggestion - It works perfect

The last issue now remains. We are using Ms Ajax update panel. When the update panel is attached to trigger when the item is clicked we get the following error:

The 'ItemClick' event on associated control 'tvSingleExpand' for the trigger in UpdatePanel 'UpdatePanel1' does not match the standard event handler signature.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: The 'ItemClick' event on associated control 'tvSingleExpand' for the trigger in UpdatePanel 'UpdatePanel1' does not match the standard event handler signature.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[InvalidOperationException: The 'ItemClick' event on associated control 'tvSingleExpand' for the trigger in UpdatePanel 'UpdatePanel1' does not match the standard event handler signature.]
System.Web.UI.AsyncPostBackTrigger.Initialize() +655
System.Web.UI.UpdatePanelTriggerCollection.Initialize() +65
System.Web.UI.UpdatePanel.Initialize() +37
System.Web.UI.UpdatePanel.OnLoad(EventArgs e) +51
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061


Any comment appreciated

eo_support
Posted: Tuesday, January 1, 2008 6:30:18 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,083
Hi,

When you add the trigger, don't set the EventName property to "ItemClick". Leave it blank. That should get it to work property.

Thanks
exorgroup
Posted: Tuesday, January 1, 2008 2:01:19 PM
Rank: Member
Groups: Member

Joined: 12/18/2007
Posts: 20
Unfortunately it did not work. I placed the dataview in a callback (you own) and attached the callback to the item click. Everything is inside the update panel from Microsoft for other functionality and now works as it should
exorgroup
Posted: Tuesday, January 1, 2008 2:18:11 PM
Rank: Member
Groups: Member

Joined: 12/18/2007
Posts: 20
Treeview is attached to database. This works fine. If user deletes the page we have to refresh the tree.

We have tried to delete the nodes and rebind to a new dataset but still the old structure is being displayed by the tree

How can we refresh the treeview?

Any comments are appreciated
eo_support
Posted: Tuesday, January 1, 2008 3:54:45 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,083
exorgroup wrote:
Treeview is attached to database. This works fine. If user deletes the page we have to refresh the tree.

We have tried to delete the nodes and rebind to a new dataset but still the old structure is being displayed by the tree

How can we refresh the treeview?

Any comments are appreciated


There is nothing special you need to do. Just make sure the TreeView is inside the CallbackPanel. Nothing outside of the CallbackPanel will be updated.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.