show tooltip in gridview

G

graphicsxp

Hi,

I would like to show a tooltip when the user move the mouse over the
first column of my gridview.

The tooltip should be bound to a field of the gridview's datasource
that correspond to the row being hovered.

How can I do that ?
 
T

Tasos Vogiatzoglou

Either you put a link with the title attribute set, or you should
devise a DHTML method (that includes javascript).

Regards,
Tasos
 
P

Patrick.O.Ige

You can use a label control
and in the label control set ToolTip='blablabls'
Patrick
 
G

graphicsxp

I've found a better way actually :

Protected Sub grdCuttings_RowDataBound(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.GridViewRowEventArgs) Handles
grdCuttings.RowDataBound
Dim item As GridViewRow = e.Row

If (e.Row.RowType = DataControlRowType.DataRow) Then
item.Cells(0).Attributes.Add("title",
Me.grdCuttings.DataKeys(item.RowIndex).Item("Headline").ToString())
End If
End Sub

Thanks
 
Joined
Sep 5, 2007
Messages
1
Reaction score
0
A better better way

Nice idea to use the RowDataBound event but your code can be simplified slightly as below.

Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
' Assumes target cell is in column 2 and the underlying data item is sDistrictName
If e.Row.RowType = DataControlRowType.DataRow Then
e.Row.Cells(2).Attributes.Add("Title", e.Row.DataItem("sDistrictName").ToString)​
End If​
End Sub
 
Last edited:
Joined
Feb 13, 2008
Messages
1
Reaction score
0
You can just do this

In your HeaderText, do this:

HeaderText="<span title='Document Size'>Size</span>"

Here's it is in context:

<asp:BoundColumn DataField="DocS" HeaderText="<span title='Document Size'>Size</span>" >
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top