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

put a color in a row depending on a validation

1 Answer 35 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ALBERT
Top achievements
Rank 1
ALBERT asked on 08 Jun 2011, 11:31 PM
need to put a red line when the column "emergency = YE"S, but not how to do it, is thispossible?.

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 09 Jun 2011, 06:32 AM
Hello Albert,

The following code shows how to change the BackGround color of row based on cell value.

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
       if (e.Item is GridDataItem)
          {
            GridDataItem item = (GridDataItem)e.Item;
            if (item["emergency"].Text == "Yes") //your condition
                  item.BackColor = System.Drawing.Color.Red;
           }
    }

Also refer the following documentation which explains how to access cells and rows in a grid.
Accessing cells and rows

-Shinu.
Tags
Grid
Asked by
ALBERT
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or