Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / web / ASP.NET

Highlighting and navigation for GridView Control

1.00/5 (1 vote)
7 May 2010CPOL 5.9K  
Navigation: protected void GVEmployees_RowCreated(object sender, GridViewRowEventArgs e){ if(e.Row.RowType==DataControlRowType.DataRow) { e.Row.Attributes[onclick] = location.href='YourPage.aspx?id= + ...
Navigation:

protected void GVEmployees_RowCreated(object sender, GridViewRowEventArgs e)
{
    if(e.Row.RowType==DataControlRowType.DataRow)
    {
        e.Row.Attributes["onclick"] = 
                 "location.href='YourPage.aspx?id=" +
                 DataBinder.Eval(e.Row.DataItem,
                                 "DataColumnNameOfYourGridView") + 
                 "'";
               
    }
}


Highlighting:

protected void GVEmployees_RowCreated(object sender, GridViewRowEventArgs e)
{
   if(e.Row.RowType!=DataControlRowType.Header || 
      e.Row.RowType!=DataControlRowType.Footer)
   {
       e.Row.Attributes.Add("onmouseout", "this.className='normalRow'");
       e.Row.Attributes.Add("onmouseover", "this.className='highlightRow'");
   }
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)