GridView Column Color Change

Discussion in 'ASP .Net' started by dm1608, Mar 1, 2006.

  1. dm1608

    dm1608 Guest

    I have a GridView that is using an ObjectDataSource to populate.

    One of my columns is named "Status" and can have a value of "Complete",
    "Error", "Active", and "Unknown". I would like to have the text for the
    word "Error" displayed in RED letters. How can I do this with a GridView
    control?
    dm1608, Mar 1, 2006
    #1
    1. Advertising

  2. dm1608

    Siva Guest

    Hi,

    One of the way to Acheive this you have to use the "RowDataBound Event" you
    can check if the text of the cell is "Error" and there you can make the
    Color of that text to Red.

    //If you know the column index , I assume the column is 3 in this sample
    code and applied.
    if(e.Row.Cells[3].Text=="Error")

    {

    e.Row.Cells[3].ForeColor = Color.Red;

    }

    hope that helps

    Regards,

    A.Sivakumar.


    "dm1608" <> wrote in message
    news:...
    >I have a GridView that is using an ObjectDataSource to populate.
    >
    > One of my columns is named "Status" and can have a value of "Complete",
    > "Error", "Active", and "Unknown". I would like to have the text for the
    > word "Error" displayed in RED letters. How can I do this with a GridView
    > control?
    >
    >
    >
    Siva, Mar 1, 2006
    #2
    1. Advertising

  3. dm1608

    dm1608 Guest

    Thanks --

    Does anyone know of a way to do this with hardcoding the column #?



    "Siva" <> wrote in message
    news:...
    > Hi,
    >
    > One of the way to Acheive this you have to use the "RowDataBound Event"
    > you can check if the text of the cell is "Error" and there you can make
    > the
    > Color of that text to Red.
    >
    > //If you know the column index , I assume the column is 3 in this sample
    > code and applied.
    > if(e.Row.Cells[3].Text=="Error")
    >
    > {
    >
    > e.Row.Cells[3].ForeColor = Color.Red;
    >
    > }
    >
    > hope that helps
    >
    > Regards,
    >
    > A.Sivakumar.
    >
    >
    > "dm1608" <> wrote in message
    > news:...
    >>I have a GridView that is using an ObjectDataSource to populate.
    >>
    >> One of my columns is named "Status" and can have a value of "Complete",
    >> "Error", "Active", and "Unknown". I would like to have the text for the
    >> word "Error" displayed in RED letters. How can I do this with a GridView
    >> control?
    >>
    >>
    >>

    >
    >
    dm1608, Mar 1, 2006
    #3
  4. dm1608

    Hari Guest

    Hi ,
    I am a begginer to ASp.Net ,so there should be some easy way for this i am
    not sure.

    I guess you can use templates for this( i dont have a full code now reg
    this) ,
    something like this.
    SomeList = (Label) e.Item.FindControl("lblsomeID");
    assuming a label is kept in that template"
    and changing thats templates label color can provide the same result.

    Regards,
    Hari
    Hari, Mar 1, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Robbo
    Replies:
    1
    Views:
    4,205
    Rick Strahl [MVP]
    Oct 18, 2003
  2. Matt Adams
    Replies:
    0
    Views:
    887
    Matt Adams
    Aug 26, 2003
  3. Keith G Hicks
    Replies:
    3
    Views:
    763
    Keith G Hicks
    Feb 18, 2008
  4. Kamaljeet Saini
    Replies:
    0
    Views:
    412
    Kamaljeet Saini
    Feb 13, 2009
  5. Replies:
    7
    Views:
    376
    Mick White
    Feb 2, 2005
Loading...

Share This Page