Welcome Guest Search | Active Topics | Sign In | Register

Treeview error Options
SteveClements
Posted: Wednesday, March 11, 2009 5:15:09 AM
Rank: Member
Groups: Member

Joined: 8/28/2008
Posts: 25
I am still really struggling with this one.

I am still in the situation that when I build the treeview and add to the parents control collection the ItemClick event does not fire, well you expand one node, click an item it DOESNT fire, it just postsback and rebinds the treeview, expand another node and click an item the ItemClick event DOES fire. Expand the same node as the first time and again it fires. Trying one node, then the same again does NOT fire the event.

I tried to create a repro for you by exporting my external datasource into an XML file, which then works. The event fires as expected.

I cant see how this should change as the code is the same, its just the data comes from elsewhere. The treeview binding knows nothing about this.

When I debug the code that sets the ItemClick event handler is hit and doesnt throw an error.

Have you any ideas what might be causing this?
eo_support
Posted: Wednesday, March 11, 2009 8:43:33 AM
Rank: Administration
Groups: Administration

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

This could be caused by a rather common ASP.NET programming mistake. When you dynamically create/initiate control with code but does not re-create it during postback exactly the same way, your server event will not fire. The issue is not in anway related to our TreeView. You can find more information here:

http://essentialobjects.com/Forum/Default.aspx?g=posts&t=1179#5018

I am not exactly sure what you meant by "event does not fire", but still "ItemClick event handler is hit". If the handler is hit, then the event has been fired. If for whatever reason things in the page do not change as you expected, it will be most likely caused by other code rather than event not being fired. I would suggest you comment code out block by block to see if you can find the triggering part.

Since we are not in a position to offer coding assistance, in order for us to look into an issue, we will have to have a repro first. If you have a repro that does work but your real application does not work, we would expect you to be able to compare the working version and non-working version to find out the difference.

Thanks!
SteveClements
Posted: Wednesday, March 11, 2009 9:17:57 AM
Rank: Member
Groups: Member

Joined: 8/28/2008
Posts: 25
What i meant is the line of code that sets the event handler on the treeview is hit...
i.e. treeview.ItemClick += new EventHandler(eventHandlerMethod)
that bit is hit, but after the control is rendered the eventHandlerMethod is not hit. (well until i open a different node, click a child item, that fires the eventhandler fine, then go back to the original node and child item...which will then fire).

The code that sets up the treeview is in the CreateChildControls method of a webpart...so is exactly the same through first load and postback.

Like i said, if i simply change the datasource to XML (which doesnt change the treeview init code at all) the events are fired as expected.

I have debugged and stepped through everyline...i see no difference between postback or different datasource.
?
eo_support
Posted: Wednesday, March 11, 2009 9:46:02 AM
Rank: Administration
Groups: Administration

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

I see what you meant about the event handler hit. I am still not quite clear about "change the datasource to XML" though. Do you set the TreeView's XmlFile or use some other way?

The other thing I can think of is, even if you have setup the DataSource, you still have to explicitly call DataBind to ensure all the nodes are created. If you do not do so, the TreeView will try to call it at a later stage, but it may be too late. The way event works is, once the TreeView receives a server event, it will try to locate the tree node first, if the tree node is not there yet (because DataBind has not been called), your server event handler will not be called.

If you have all the code inside your CreateChildControls, you may want to call EnsureChildControls inside your OnInit to make sure it is being called.

Thanks!


SteveClements
Posted: Wednesday, March 11, 2009 11:16:29 AM
Rank: Member
Groups: Member

Joined: 8/28/2008
Posts: 25
I dont set the treeview XML, i iterate through the returned data (whether that be XML or some other source) new'ing up TreeNodes, setting the properties and adding them to the treeview node collection.

eoTv = new EO.Web.TreeView();
eoTv.ID = "EOTreeView";
eoTv.ForeColor = System.Drawing.Color.Black;
eoTv.AllowDragDrop = false;
eoTv.CssBlock = "<style type='text/css'>.eoTree{font-size: 11px; cursor: hand; margin-top:-5px;}</style>";
eoTv.CssClass = "eoTree";
eoTv.RaisesServerEvent = true;

eoTv.ItemClick += new EO.Web.NavigationItemEventHandler(eoTv_ItemClick);
eoTv.ItemPopulate += new EO.Web.NavigationItemEventHandler(eoTv_ItemPopulate);

// ... the looping here through datasource to create and add treenodes.

eo_support
Posted: Wednesday, March 11, 2009 11:29:29 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
If you are reading the data, I do not see any difference from the TreeView point of view. The code should be exactly the same to the TreeView. The TreeView doesn't even know you get your data from XML or your database. So I do not believe there is any reason for the TreeView to behave differently just because you are reading from XML. Something got to be different in your code or data and it is impossible for us to find that out for you unless you can provide a repro sample. As such we do not see anything else we can do except for closing this issue until a repro is provided.


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.