I'm setting the background colors of the nodes in my treeview by binding to a CSS field in my database.
In my actual application, the nodes on the tree represent tasks and the colors indicate the priority. The same webform includes some controls to update the task. At the end of this process, I need to update the selected node color. Can someone tell me the code that I need to do this?
Here's a simplified code sample. When I try setting the node colors in code, only the text portion of the node is set. In the screen shot shown that's attached to this thread, notice how only the Node 1-1 section is colored in red. The rest of the node remains green.
What code do I need to change the color of the entire node?
Many thanks,
Tim
<html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title></title> <style type="text/css"> .green { background-color: green; } .red { background-color: red; } </style></head><body> <form id="form1" runat="server"> <div> <asp:UpdatePanel runat="server"> <ContentTemplate> <telerik:RadScriptManager ID="RadScriptManager1" runat="server" /> <telerik:RadTreeView ID="RadTreeView1" runat="server" DataFieldID="UniqueId" DataFieldParentID="parentid" DataTextField="NodeText" DataValueField="UniqueId"> <ContextMenus> </ContextMenus> <DataBindings> <telerik:RadTreeNodeBinding ContentCssClassField="CssClass" /> </DataBindings> </telerik:RadTreeView> </ContentTemplate> </asp:UpdatePanel> <asp:LinkButton Text="Change Color" runat="server" ID="changeLink"/> </div> </form></body></html>Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then Dim values = {New With {.UniqueId = "0", .parentid = Nothing, .NodeText = "Node 1", .CssClass = "red"}, New With {.UniqueId = "1", .parentid = Nothing, .NodeText = "Node 1-1", .CssClass = "green"} } RadTreeView1.DataSource = values RadTreeView1.DataBind() End IfEnd SubProtected Sub changeLink_Click(sender As Object, e As System.EventArgs) Handles changeLink.Click 'None of these color the entire row. what's the correct syntax to use? RadTreeView1.FindNodeByValue("1").BackColor = Color.Red RadTreeView1.FindNodeByValue("1").CssClass = "red"End Sub