// Change Wait Time Cell Rows CHECK THE LOGIC HERE
if (e.Row.RowType == DataControlRowType.DataRow )
{
// This line will get the reference to the underlying row
DataRowView _row = (DataRowView)e.Row.DataItem;
if (_row != null)
{
// get the field value which you want to compare and
// convert to the corresponding data type
// i assume the fieldName is of int type
int _field = Convert.ToInt32(_row.Row["RegWaitTime"]);
{
if (!DBNull.Value.Equals(_row.Row["RegWaitTime"]))
if (_field > 30)
{
e.Row.Cells[9].BackColor = System.Drawing.Color.Red;
e.Row.Cells[9].Style.Add("color", "white");
}
else
e.Row.Cells[9].BackColor = System.Drawing.Color.Green;
e.Row.Cells[9].Style.Add("color", "white");
}
}
}
if (e.Row.RowType == DataControlRowType.DataRow)
{
// This line will get the reference to the underlying row
DataRowView _row2 = (DataRowView)e.Row.DataItem;
if (_row2 != null)
{
// get the field value which you want to compare and
// convert to the corresponding data type
// i assume the fieldName is of int type
int _field = Convert.ToInt32(_row2.Row["TotalRegTime"]);
if (!DBNull.Value.Equals(_row2.Row["TotalRegTime"]))
{
if (_field > 30)
{
e.Row.Cells[10].BackColor = System.Drawing.Color.Red;
e.Row.Cells[10].Style.Add("color", "white");
}
else
e.Row.Cells[10].BackColor = System.Drawing.Color.Green;
e.Row.Cells[10].Style.Add("color", "white");
}
}
}
Do more with
int _field = Convert.ToInt32(_row2.Row["TotalRegTime"]);
if (!DBNull.Value.Equals(_row2.Row["TotalRegTime"]))
{
becomesif(!DBNull.Value.Equals(_row2.Row["TotalRegTime"])) {
int _field = Convert.ToInt32(_row2.Row["TotalRegTime"]);
Premium Content
You need an Expert Office subscription to comment.Start Free Trial