change row backcolor in gridrow

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;
}
}
}
 
M

mcnewsxp

i placed this in the RowDataBound event

if (e.Row.RowType == DataControlRowType.DataRow) {
DataRowView drv = (DataRowView)e.Row.DataItem;

//Creat a private var sEvent
if (sEvent == Convert.ToString(drv["ATT_EVENT_ID"]))
{
e.Row.BackColor = System.Drawing.Color.FromName("#E56E94");
}
else
{
e.Row.BackColor = System.Drawing.Color.FromName("gray");
sEvent = Convert.ToString(drv["ATT_EVENT_ID"]);
}
 
J

Jeff Johnson

i want to alternate the backcolor in my gridview when ever a group value
changes.

Given that your questions are so Web-specific, I would highly recommend you
post them in the ASP.NET group. You're not really asking about C# here; that
just happens to be the language you're using. I'm not trying to shoo you
off, but rather I think you'll get more help from a different group.
 
M

mcnewsxp

Given that your questions are so Web-specific, I would highly recommend you

post them in the ASP.NET group. You're not really asking about C# here; that

just happens to be the language you're using. I'm not trying to shoo you

off, but rather I think you'll get more help from a different group.

i wasn't aware of the group. for some reason i like this old fashioned google group format better than any of those webified forums you have to join. so much crap on the page.
 
A

Arne Vajhøj

i wasn't aware of the group. for some reason i like this old
fashioned google group format better than any of those webified
forums you have to join. so much crap on the page.

microsoft.public.dotnet.framework.aspnet still exists, but not much
traffic.

Arne
 
J

Jeff Johnson

microsoft.public.dotnet.framework.aspnet still exists, but not much
traffic.

Unfortunately it seems that the folks who do Web work prefer to...use the
Web. Go figure.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top