Data bind Gridview as previous projects. Watch Video
Click on the Gridview and open the property windows and click on Event icon.
Double click on RowCreated Event, coding window will open. and past the below code.
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
decimal RowValue = default(decimal);
RowValue = decimal.Remainder(e.Row.RowIndex, 2);
if (!(e.Row.RowIndex == -1))
{
e.Row.Attributes.Add("OnMouseOver", "this.style.backgroundColor = 'lightsteelblue';");
}
if (RowValue == 0 & !(e.Row.RowIndex == -1))
{
e.Row.Attributes.Add("OnMouseOut", "this.style.backgroundColor = '';");
}
else if (!(RowValue == 0) & !(e.Row.RowIndex == -1))
{
e.Row.Attributes.Add("OnMouseOut", "this.style.backgroundColor = '';");
}
}
Watch Video
0 comments:
Post a Comment