Adding the solution given by OP hiself/herself.
In the
RowCreated
I have the following code
bool Row = false;
if ((id != null) && (DataBinder.Eval(e.Row.DataItem, "id") != null))
{
if (id != (DataBinder.Eval(e.Row.DataItem, "id").ToString()))
Row = true;
}
if ((id != null) && (DataBinder.Eval(e.Row.DataItem, "id") == null))
{
Row = true;
rowIndex = 0;
}
if (Row)
{
GridView GridView1 = (GridView)sender;
GridView1.HeaderRow.BackColor = System.Drawing.Color.Orange;
GridViewRow NewTotalRow = new GridViewRow(0, 0, DataControlRowType.DataRow, DataControlRowState.Insert);
NewTotalRow.Font.Bold = true;
TableCell HeaderCell1 = new TableCell();
HeaderCell1.ColumnSpan = 6;
NewTotalRow.Cells.Add(HeaderCell);
HeaderCell1 = new TableCell();
HeaderCell1.HorizontalAlign = HorizontalAlign.Right;
HeaderCell1.Text = tohrs.ToString();
NewTotalRow.Cells.Add(HeaderCell1);
GridView1.Controls[0].Controls.AddAt(e.Row.RowIndex + rowIndex, NewTotalRow);
rowIndex++;
tohrs = 0;
}
}