How to display with different font color

Discussion in 'ASP .Net' started by ad, Apr 16, 2005.

  1. ad

    ad Guest

    I use a dataGrid to list the scores of students.
    If the score is less than 60, I want the score display with font of red.
    The other will display with blue font.
    How can I do that?
    ad, Apr 16, 2005
    #1
    1. Advertising

  2. Try looking at this at
    :-http://authors.aspalliance.com/Colt/SourceCode/HelperFunction.html
    That should help you.
    Patrick



    *** Sent via Developersdex http://www.developersdex.com ***
    Patrick Olurotimi Ige, Apr 16, 2005
    #2
    1. Advertising

  3. ad

    Jeebu Guest

    hi,
    u can use the grid ItemDataBound event for that.

    DataGridItem Gridtem = e.Item;
    int marks;
    DataRowView dataRowView = (DataRowView)e.Item.DataItem;
    ListItemType itemType = e.Item.ItemType;
    string str = string.empty;
    if( itemType==ListItemType.Item || itemType==ListItemType.AlternatingItem )]
    {

    marks = int.parse(dataRowView.Row["Fieldname"].ToString());

    if(marks<60)
    {
    str += "<font color='red'>" + marks.tostring() + "</font>";

    }
    else
    {
    str += "<font color='blue'>" + marks.tostring() + "</font>";

    }

    Gridtem.cells[specify the cell number of marks].text=str;

    }

    "ad" <> wrote in message news:%...
    > I use a dataGrid to list the scores of students.
    > If the score is less than 60, I want the score display with font of red.
    > The other will display with blue font.
    > How can I do that?
    >
    >
    Jeebu, Apr 18, 2005
    #3
    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. mttc
    Replies:
    2
    Views:
    2,354
    Roedy Green
    Jul 3, 2009
  2. NH
    Replies:
    1
    Views:
    120
    Ken Cox [Microsoft MVP]
    Apr 15, 2004
  3. Kamaljeet Saini
    Replies:
    0
    Views:
    364
    Kamaljeet Saini
    Feb 13, 2009
  4. sed_y
    Replies:
    0
    Views:
    953
    sed_y
    Feb 15, 2012
  5. Replies:
    1
    Views:
    255
    marss
    Feb 14, 2007
Loading...

Share This Page