highlight / change appearance of one grid item

4 posts, 2 answers
  1. Mario
    Mario avatar
    75 posts
    Member since:
    Jun 2009

    Posted 07 Sep 2009 Link to this post

    Hi,

    i got a grid in which one item is more important than the others.

    How can i change its appearance or highlight it?

    Im currently there but i dont know what to do..

    protected void RadGridHistory_ItemDataBound(object sender, GridItemEventArgs e) 
            { 
                if (e.Item is GridDataItem) 
                { 
                    GridDataItem item = (GridDataItem)e.Item; 
     
                    string key = item.KeyValues; 
                    int id = ParseIdFromKeyValueString(key); 
     
                    if (id == Convert.ToInt32(Request["id"].ToString())) 
                    { 
                        // change appearance. like bold text of the GridBoundColumns
                    } 
                } 
            } 

    thx Mario
  2. Answer
    Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 07 Sep 2009 Link to this post

    Hi Mario,

    To achieve the desired functionality I suggest you examine the following help topic:
    Conditional Formatting for rows/cells on ItemDataBound

    Kind regards,
    Pavlina
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 07 Sep 2009 Link to this post

    Hi Mario,

    Try the following code in order to change the appearance of cell value based on condition.

    C#:
     
    protected void RadGridHistory_ItemDataBound(object sender, GridItemEventArgs e)   
    {   
        if (e.Item is GridDataItem)   
        {   
            GridDataItem item = (GridDataItem)e.Item;   
            string key = item.KeyValues;   
            int id = ParseIdFromKeyValueString(key);   
            if (id == Convert.ToInt32(Request["id"].ToString()))   
            {   
                // change appearance. like bold text of the GridBoundColumns  
                   item["CustomerID"].ForeColor = System.Drawing.Color.Red;  // Where CustomerID is the ColumnUniqueName 
                   item["CustomerID"].Style.Add("font-weight""bold");              
            }   
        }   
    }   

    -Shinu.
  5. Mario
    Mario avatar
    75 posts
    Member since:
    Jun 2009

    Posted 07 Sep 2009 Link to this post

    thx Shinu, guess that was an easier one :p
Back to Top