problem with clicking on already selected node in TreeView

N

Nadav Popplewell

Hi Everybody,

I've got a problem with handling the postback when clicking on already
selected node in treeview:
If you click on a non selected tree node then the SelectedNodeChanged is
called,
but if you click on the selected tree node then a postback is generated but
no event is called.
Why is this?
And How do I handle it?
I know I can use postEventSourceID/postEventArgumentID to get the
information from the Request, but I'm not really supposed to use these right?

Thanks,
Nadav
 
W

Walter Wang [MSFT]

Hi Nadav,

I think this is by design behavior that this event will only get fired if
the selected node is really "changed" (different with previous selected
node).

Could you please tell me what are you doing in SelectedNodeChanged event?
Based on the actual requirement, we may have other place to do the job.

Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
N

Nadav Popplewell

Hi Walter,

It's a bit complicated.
I've got a GridView where I change the row in the RowDataBound event.
If I don't DataBind the GridView I don't see the row properly.
But I don't want to DataBind the GridView on every postback because I've run
into problems with event handling of controls in the GridView templates if I
DataBind the GridView several times.

I think that if clicking on the selected node should have no effect then it
sould not generate a postback.
It it should have an effect then there should be an event handler to handle
it.
The fact that it performs a postback but there is no event handler for the
postback does not make sense to me.

Nadav
 
W

Walter Wang [MSFT]

Hi Nadav,

Thanks for your quick reply.

Yes I understand your concern here. However, since different nature between
WinForm and ASP.NET application, we could only know that the selected node
is not changed after the postback is issued.

Based on my understanding, you're currently determining whether or not to
bind a GridView in the TreeView's SelectedNodeChanged event? Does that mean
the GridView only gets databinding when TreeView's SelectedNode is not
null? If this is the case, I think you can call GridView.DataBind() in
Page_Load whenever TreeView.SelectedNode is not null. What do you think?

Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
N

Nadav Popplewell

Hi Walter,
Based on my understanding, you're currently determining whether or not to
bind a GridView in the TreeView's SelectedNodeChanged event? Does that mean
Yes, if the SelectedNodeChanged I update the information displayed and
databind the gridview. If the selected node didn't change OR if another event
handler is going to databind the gridview I don't want to DataBind again in
the Page_Load().
the GridView only gets databinding when TreeView's SelectedNode is not
null? If this is the case, I think you can call GridView.DataBind() in
Page_Load whenever TreeView.SelectedNode is not null. What do you think?

I wish it was that simple. The SelectedNodeChanged (or any other event) is
NOT called when clicking on the currently selected node so I have to handle
it in the Page_Load event, however in order to detect that the postback is
caused by clicking on a node in the TreeView I have to access the __Event*
form fields which I'm not supposed to do.
Another problem I've discovered is that when clicking on a non selected node
by the time Page_Load is called the SelectedNode property is already updated
so I have to save the old selected node path in the view state so I can
deteremine in the Page_Load (which is called before the SelectedNodeChanged)
if the postback is caused by clicking on the selected node or on a different
node.
It a real pity that the TreeView does not perform these tasks for you...

Nadav
 
W

Walter Wang [MSFT]

Hi Nadav,

Yes we have two issues of the TreeView here:

1) The SelectedNodeChanged event is only fired when the node is really
changed: it will not fire if you clicking on the already selected node but
the postback is still taken place.

2) The previously selected node is not stored on the TreeView, you have to
do that yourself.

I fully understand that these issues caused inconvenience for your project.
However, please rest assured that we're continuously improving our products
and it's customer like you help us to do better with such feedback. I will
surely help forward your feedback to product team. You're also welcome to
submit your feedback at
http://connect.microsoft.com/Main/content/content.aspx?ContentID=2220 which
is monitored by our product team directly and you will also receive direct
response from them.

For now, we have to use some workaround to deal with these limitations,
please feel free to let me know if you need further information for the
workaround. Thanks.

Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
L

LaBrina Loving

Hi,

I am facing this same problem. Has there been any updates from
Microsoft to handle this or does it have to be handled in the Page_Load
event? Also can you provide me code example on how to handle this?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top