Changing the Previous Treeview node back color

  • Thread starter Thread starter Mike Collins
  • Start date Start date
M

Mike Collins

I have six treeviews on a page. Each one is nested inside an accordion pane.
When I click on a node, it turns yellow. When I click on a node in another
tree, I would like the previous selected node to change back from yellow to
its original color. The two different ways I have tried below do not work. Am
I doing something wrong?

protected void tvAccountSetup_SelectedNodeChanged(object sender, EventArgs e)
{
string cssStyle = "color: #FFFFFF; background: none;
font-size:12pt;font-weight:bold;";
tvProgram.SelectedNodeStyle.CssClass = cssStyle;
if (tvProgram.SelectedNode != null)
{
tvProgram.SelectedNodeStyle.BackColor = System.Drawing.Color.Beige;
tvProgram.SelectedNode.Selected = false;
}
}
 
yes. just selecting a node in another tree will not deselect a node in
the current tree. your code will have to determine which tree did the
postback. although for performance you should do this in javascript
rather than via a postback.

-- bruce (sqlwork.com)
 
Back
Top