Monday, April 21, 2008

ASP.NET GridView Tips - ToolTip 2

If you want to show a column value in a row tooltip, you can use the following code in Codebehind from the RowDataBound event of the GridView (VB.NET). Additionally, when you hover the mouse over the gridview row, the row will appear with underline and with 'hand' cursor.

Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound

If e.Row.RowType = DataControlRowType.DataRow Then

e.Row.ToolTip = e.Row.DataItem("Description").ToString

e.Row.Attributes.Add("onmouseover", "'hand';'underline';")
e.Row.Attributes.Add("onmouseout", "'none';")

End If
End Sub

No comments: