give control in datalist color

Posted by KareemSaad on Stack Overflow See other posts from Stack Overflow or by KareemSaad
Published on 2010-04-14T07:54:59Z Indexed on 2010/04/14 8:33 UTC
Read the original article Hit count: 290

Filed under:

I had datalist as menu that display categories and subs and I want to give red color or css for the selected item(category or sub) I tried but I had a problem This is my code

 private  Label Lb;

 protected void Page_Load(object sender, EventArgs e)
{


}

protected void dlCategory_ItemDataBound(object sender, DataListItemEventArgs e)

{
    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
    {
         Lb = (Label)e.Item.FindControl("LblCat");

    }


}



protected void dlCategory_SelectedIndexChanged(object sender, EventArgs e)
{


        Lb.ForeColor = System.Drawing.Color.Red;


}

}

© Stack Overflow or respective owner

Related posts about c#