This is a simple technique used in the RowDataBound event of a GridView so that its Entire Row acts as a HyperLink.
For Visual effects styles are applied at mouseover and mouseout.
The cursor is also given a hand like appearance to show the row is a hyperlink
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes["onmouseover"] = "this.style.color='DodgerBlue';this.style.cursor='hand';";
e.Row.Attributes["onmouseout"] = "this.style.color='Black';";
e.Row.Attributes["onclick"] = "window.navigate('NavigatedPage.aspx?id=" + e.Row.RowIndex + "')";
// can send anything as querystring
}
}
1 comments on "GridViewRow as Hyperlink"
Subscribe in a Reader
Thanks!! it works a part only but cannt redirect to next page on onclick .can u give more solution.
Post a Comment