This is a migrated thread and some comments may be shown as answers.

Change color of treeview text from sql

1 Answer 67 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Herman
Top achievements
Rank 1
Herman asked on 05 Jul 2011, 09:40 PM
Apologies for my English

I create my treeview from a SQL database. In my database  have with all the other data  two columns
1. Active(bit) true or false
2. Status(nvchar)

when the treeview is build on the load i want the colors to look like this

  • Node titles displayed in “Green” RGB[102, 188, 41] are Active (Active Flag is true) nodes with an approval status of “Approved”
  • Node titles displayed in “Amber” RGB [255, 145, 75] are Active nodes that have an approval status of “Pending”
  • Node titles displayed in “Red” RGB [210, 90, 90] are Active nodes that have an approval status of “Rejected”
  • Node titles displayed in “Grey” RGB[128, 128, 128] are Inactive regardless of the value of the approval status.


1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 06 Jul 2011, 08:43 AM
Hello Herman,

You can set the desired color in the NodeDataBound event. Here is the sample code.
C#:
protected void RadTreeView1_NodeDataBound(object sender, Telerik.Web.UI.RadTreeNodeEventArgs e)
   {
       if (e.Node.Text == "Test")
       {
           e.Node.ForeColor = System.Drawing.Color.Red;
       }
   }

Thanks,
Shinu.
Tags
TreeView
Asked by
Herman
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or