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. Advertisements

  2. Try looking at this at
    :-http://authors.aspalliance.com/Colt/SourceCode/HelperFunction.html
    That should help you.
    Patrick
     
    Patrick Olurotimi Ige, Apr 16, 2005
    #2
    1. Advertisements

  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;

    }
     
    Jeebu, Apr 18, 2005
    #3
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.