Changing color of the row of grid on doing on putting the mouse over to it. It is generally used to highlighted the row of grid. You need to put the code while doing the mouse over the color of the row should get change and again once you remove the mouse from the row its getting old color.
You can find out both from there, Below code is handing both the event mouse over and mouse out. It should be any name but just for to get it operation perform giving the proper mouse over name. There is two argument passing GridView : here you need to pass the gridview name as you defined in application[ see the calling way].
And grid view row event.
@ Calling above method
it should be called in Row Created event of the grid. and in argument passing the grid name and event "e" as the argument.
protected void
You can find out both from there, Below code is handing both the event mouse over and mouse out. It should be any name but just for to get it operation perform giving the proper mouse over name. There is two argument passing GridView : here you need to pass the gridview name as you defined in application[ see the calling way].
And grid view row event.
//Code Snippet for change row color of grid on mouse over
@Method decalartion
protected void GridRowColor_OnMouseOver(GridView grd, GridViewRowEventArgs e)
{ string onmouseoverStyle = "this.style.backgroundColor='#F4C359'";
string onmouseoutStyle = "this.style.backgroundColor='#@BackColor'";
string rowBackColor = string.Empty;
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.RowState == DataControlRowState.Alternate)
{
rowBackColor =
grd.AlternatingRowStyle.BackColor.Name.Remove(0, 2);
}
else
{
rowBackColor =
grd.RowStyle.BackColor.Name.Remove(0, 2);
}
e.Row.Attributes.Add("onmouseover",
onmouseoverStyle);
//
e.Row.Attributes.Add("onmouseover", OnclickStyle);
e.Row.Attributes.Add("onmouseout",
onmouseoutStyle.Replace("@BackColor", rowBackColor));
}
}
grdCGGoodsDesc_RowCreated(object sender, GridViewRowEventArgs e)
{
GridRowColor_OnMouseOver(grdCGGoodsDesc, e);
}
No comments:
Post a Comment