Tooltip on cell in DataGrid?

L

Lars Netzel

I need to have a Tooltip on each Cell in a datagrid, I don't know how to do
this. I'm using Styles to the datagrid (Which I asume most people do since
you never need to show all the fields from the source).

The Cell I want a tooltip on is styled with a textboxcolumn and the TextBox
Object in that TextBox Column doesn't seem to have a property called
Tooltip.. so i'm sorta stranded here...

Best regards/
Lars
 
G

Guest

Lars, based on your post above, maybe you've already figured this out:

Private Sub grdMenu_ItemDataBound(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) _
Handles grdMenu.ItemDataBound

If e.Item.ItemType = ListItemType.AlternatingItem Or _
e.Item.ItemType = ListItemType.Item Or _
e.Item.ItemType = ListItemType.SelectedItem Then

Dim drv As DataRowView = CType(e.Item.DataItem, DataRowView)
Dim ctl As WebControl = CType(e.Item.FindControl("lblDesc"),
WebControl)
ctl.ToolTip = drv("ExtDesc").ToString

End If

The gist is that at ItemDataBound, go get your control, and then add your
text to the tooltip property. In my case the grid shows "Description" for an
item, and I put the "Extended Description" in the tooltip.

hth,

Bill
 

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

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top