Click here to Skip to main content
15,902,114 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to add css class only on first div in listview ?
Posted

you can use listview ItemDataBound event.

put if condition for first item and apply css..
 
Share this answer
 
Comments
abid zahid 8-May-14 4:17am    
thanks for reply can you explain it little bit more pls?
this is one example ...based on your requirement change inner things..

C#
protected void ListView1_ItemDataBound(object sender, ListViewItemEventArgs e)
    {
        if (e.Item.ItemType == ListViewItemType.DataItem)
        {
            ListViewDataItem item = (ListViewDataItem)e.Item;
            string locale = (string)DataBinder.Eval(item.DataItem, "city");
            // not sure how to do this from here on.
            if (locale == "Denver")
            {
                System.Web.UI.HtmlControls.HtmlTableRow cell =
                    (System.Web.UI.HtmlControls.HtmlTableRow)e.Item.FindControl("TableRowID");
                cell.BgColor = System.Drawing.Color.AliceBlue.ToString();
            }
        }
    }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900