M
mcnewsxp
i want to alternate the backcolor in my gridview when ever a group value changes. so i may have 3 rows for group 1, 2 for group 2, 1 for group 3, 5 for group 5 etc. so i want to alternate color the color.
the code bolow is in my method to bind the gridview. i get row count, but no data that the code can find.
gvATTENDANCE_TODAY.DataSource = dvATTENDANCE_TODAY;
gvATTENDANCE_TODAY.DataBind();
string sEvent = gvATTENDANCE_TODAY.FindControl("EventID").ToString();
foreach (GridViewRow row in this.gvATTENDANCE_TODAY.Rows)
{
if (row.RowType == DataControlRowType.DataRow)
{
// this code doesn't execute
if (sEvent != row.Cells[1].Text)
{
row.BackColor = System.Drawing.Color.LightPink;
sEvent = row.Cells[1].Text;
}
else
{
row.BackColor = System.Drawing.Color.LightSeaGreen;
}
}
}
the code bolow is in my method to bind the gridview. i get row count, but no data that the code can find.
gvATTENDANCE_TODAY.DataSource = dvATTENDANCE_TODAY;
gvATTENDANCE_TODAY.DataBind();
string sEvent = gvATTENDANCE_TODAY.FindControl("EventID").ToString();
foreach (GridViewRow row in this.gvATTENDANCE_TODAY.Rows)
{
if (row.RowType == DataControlRowType.DataRow)
{
// this code doesn't execute
if (sEvent != row.Cells[1].Text)
{
row.BackColor = System.Drawing.Color.LightPink;
sEvent = row.Cells[1].Text;
}
else
{
row.BackColor = System.Drawing.Color.LightSeaGreen;
}
}
}