This is a migrated thread and some comments may be shown as answers.

RadGrid style row at server side

2 Answers 56 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Amit
Top achievements
Rank 1
Amit asked on 31 Oct 2012, 05:42 AM
Hello,

I have grid in which I have populate the data for two dates , Now I want to show the future date data in gray color and todays date  data in white color at runtime(Server side). or any how.
How should I do this Please give me suggestion.

like this grid rows
_______________________________________
|                   Header row                                       |
_______________________________________
|           Todays date data in white                         |
_______________________________________
|           Future date data in gray color                   |
_______________________________________
|           Future date data in gray color                   |
_______________________________________
|           Future date data in gray color                   |
_______________________________________

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 31 Oct 2012, 05:57 AM
Hi,

Please try the following code snippet to give colors for date.

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem item = (GridDataItem)e.Item;
        TableCell cell = (TableCell)item["UniqueName"];
        DateTime date = DateTime.Parse(cell.Text);
 
        if (date > (DateTime.Today))
        {
            cell.ForeColor = Color.Gray;
        }
        else if(date == (DateTime.Today))
        {
            cell.ForeColor = Color.White;
        }
    }
}

Thanks,
Shinu.
0
Amit
Top achievements
Rank 1
answered on 31 Oct 2012, 11:35 AM
Thank you
shinu
Tags
Grid
Asked by
Amit
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Amit
Top achievements
Rank 1
Share this question
or