Changing the color of Gridview Row Dynamically

Rate It (1)

Last post 12-05-2007 7:55 AM by vijayvrr_2001. 3 replies.

Sort Posts:

  • Changing the color of Gridview Row Dynamically

    12-05-2007, 2:02 AM
    • Member
      46 point Member
    • itsnasir
    • Member since 11-23-2007, 7:16 AM
    • Posts 49

    hi

    I m creating a page containg GridView in a update panel... which shows my tasks and their status approved/disapproved... wot i need is, if my task is not approved then the row color in gridview must be changed to Red color and for approved task something like Green color etc etc,....

     can anyone help me in this scenario... is there any javascript code to acheive this functionality...

     Looking forward for your kind response

    Thanks

    Nasir Ibrahim

  • Re: Changing the color of Gridview Row Dynamically

    12-05-2007, 5:26 AM
    Answer
    • Contributor
      2,341 point Contributor
    • vijayvrr_2001
    • Member since 09-19-2007, 10:04 AM
    • Posts 394

    Hi

    How about handling this in the server side like this

    In Gridview1_RowCreated event

    1    If (e.Row.RowType == DataControlRowType.DataRow)
    2    {
    3       string status = (string)Databinder.Eval(e.Row.DataItem,"Status");
    4      
    5       if (status == "NotApproved")
    6       {
    7         e.Row.BackColor = Color.Red;
    8         //optionally
    9         e.Row.ForeColor = Color.
    10      }
    11      // and so for other statuses
    12   }

     Hope this is agreeable.

    VJ

    If the reply answered your question please Mark it as "Answered". This would help people know that the question has been answered.
  • Re: Changing the color of Gridview Row Dynamically

    12-05-2007, 7:39 AM
    • Member
      46 point Member
    • itsnasir
    • Member since 11-23-2007, 7:16 AM
    • Posts 49

    Thank you sooooooooooooooo muchBig Smile

  • Re: Changing the color of Gridview Row Dynamically

    12-05-2007, 7:55 AM
    Answer
    • Contributor
      2,341 point Contributor
    • vijayvrr_2001
    • Member since 09-19-2007, 10:04 AM
    • Posts 394

    You are most welcome my friend. Smile

    VJ

    If the reply answered your question please Mark it as "Answered". This would help people know that the question has been answered.
Page 1 of 1 (4 items)