GridView Row Tooltip hover
Posted on: Tue Apr 21 11:21:55 -0700 2009. Updated on: Tue Apr 21 11:27:31 -0700 2009.
Category: DotNet
Category: DotNet
This is a neat trick to get a tooltip when a user hovers over a row in a gridview. It is very simple and uses standards.
Simply attach something like this to the GridView's RowDataBound event:
protected void GridViewEligibleProducts_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
// get the row view to be able to access data from the binding object
DataRowView drv = (DataRowView)e.Row.DataItem;
// lets me type safe, optional
ProductsSvc.DSProducts.AgencyEligibleProductsRow thisRow = (ProductsSvc.DSProducts.AgencyEligibleProductsRow)drv.Row;
// this is the magic to get the tooltip. You could put anything as the 2nd parameter
e.Row.Attributes.Add("title", (thisRow.IsdescriptionNull() ? "" : thisRow.description));
}
}