Wednesday, September 2, 2009

Highlight Gridview's Row on mouseHover

in Gridview we have seen most of the time we one we take move hover to any row , size of that row or background color or any animation get happen you can do that using css, or java script also.

here i have do that using java script

function gvHigh(tRow,showAct)
{
if (showAct)
{
tRow.style.backgroundColor = '#ff32ss';
}
else
{
tRow.style.backgroundColor = '#ffffff';
}
}

function urlloca(Url)
{
document.location.href = Url;
}



and Define onrowCreated function like this and put your code behind here


protected void gv1_onRowCreated(object sender, EventArgs e)
{
foreach (GridViewRow gvRow in gv1.Rows)
{
gvRow.Attributes["onmouseover"] = "highlight(this, true);";
gvRow.Attributes["onmouseout"] = "highlight(this, false);";
HttpResponse myHttpResponse = Response;
HtmlTextWriter myHtmlTextWriter = new HtmlTextWriter(myHttpResponse.Output);
gvRow.Attributes.AddAttributes(myHtmlTextWriter);
}

}



that's it it will help you.
thank you.

No comments:

Post a Comment