I'm writing asp.net code(web form ) with treeVeiw tags Here I'm added tage treeVeiw with ParentNodeStyle ,leafNodestyle,images ,Hovernodestyle like following code :
<asp:TreeView runat="server" ID="TreeView1" CssClass="tbl"
OnSelectedNodeChanged="TreeView1_SelectedNodeChanged" BorderColor="#999999" BorderStyle="None"
BorderWidth="2px" CollapseImageToolTip="Collapse {0}"
CollapseImageUrl="~/InternalKuah/WebApplication1/WebApplication1/images/menuDown.png"
ExpandImageUrl="~/InternalKuah/WebApplication1/WebApplication1/images/menuUp.png" Font-
Bold="True" ForeColor="#CCCCCC" NodeWrap="True" Font-Size="Larger"
NoExpandImageUrl="~/InternalKuah/WebApplication1/WebApplication1/images/MenuUp.png"
OnTreeNodeExpanded="TreeView1_TreeNodeExpanded1">
<LeafNodeStyle ChildNodesPadding="5px"
Font-Bold="True" Font-Names="Bahnschrift" Font-Size="Large"
BorderWidth="1px" BorderColor="Black" BorderStyle="Outset"
ForeColor="Black"
BackColor="AliceBlue" NodeSpacing="2px" />
<ParentNodeStyle BackColor="Chocolate" BorderColor="#999999"
BorderStyle="Solid" NodeSpacing="2px" BorderWidth="2px"
ChildNodesPadding="2px" ImageUrl="WebApplication1/images/MenuUp.png"
Font-Bold="True" />
<SelectedNodeStyle BackColor="#2591b0" BorderColor="#999999"
BorderStyle="Ridge" BorderWidth="2px"
Font-Bold="True" Font-Size="Larger" Font-Underline="True"
ForeColor="Black" ChildNodesPadding="2px"
CssClass="SelectedNodeStyle" />
<LevelStyles>
<asp:TreeNodeStyle ChildNodesPadding="10"
Font-Bold="true"
Font-Size="12pt"
ForeColor="DarkGreen"/>
<asp:TreeNodeStyle ChildNodesPadding="5"
Font-Bold="true"
Font-Size="10pt"/>
<asp:TreeNodeStyle ChildNodesPadding="5"
Font-UnderLine="true"
Font-Size="10pt"/>
<asp:TreeNodeStyle ChildNodesPadding="10"
Font-Size="8pt"/>
</LevelStyles>
</asp:TreeView>
it will filled according to database retrieved the c# code like this :
protected void Page_Load(object sender, EventArgs e)
{
TreeNode node,SubNode;
if (!IsPostBack)
{
ds = data_lnk.xxx(user, "iso", "52");
if (ds.Tables[0].Rows.Count > 0)
{
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
node = new TreeNode();
node.Text = ds.Tables[0].Rows[i]["name"].ToString();
// node.SelectAction = TreeNodeSelectAction.None;
TreeView1.Nodes.Add(node);
dsSub = data_lnk.yyy(user, "", "52", ds.Tables[0].Rows[i]["dep"].ToString());
if (dsSub.Tables[0].Rows.Count > 0)
{
for (int j = 0; j < dsSub.Tables[0].Rows.Count; j++)
{
SubNode = new TreeNode();
SubNode.NavigateUrl = dsSub.Tables[0].Rows[j]["path"].ToString();
SubNode.Text = dsSub.Tables[0].Rows[j]["file_name"].ToString();
TreeView1.Nodes[i].ChildNodes.Add(SubNode);
if (dsSub.Tables[0].Rows[j]["color"].ToString() == "green")
{
//Here we should the Node if green in green color
}
else
{
//Here color leaf node in red color
}
}
}
}
}
TreeView1.CollapseAll();
}
}
'''
My problem how to color the background( or apply any style) in LeafTreeNode /ParentTreeNode according to code