This is a migrated thread and some comments may be shown as answers.

RadToolTip in RadGrid

3 Answers 195 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Eric
Top achievements
Rank 1
Eric asked on 21 Apr 2009, 07:38 PM

I am trying to add the radtooltip into an item template of a dynamically created table.  I have the follwing code

  Public Sub InstantiateIn(ByVal container As System.Web.UI.Control) Implements ITemplate.InstantiateIn  
            gridLabel = New Label()  
            AddHandler gridLabel.DataBinding, AddressOf gridLabel_DataBinding  
            gridCheck = New CheckBox()  
            AddHandler gridCheck.DataBinding, AddressOf GridCheck_DataBinding  
            gridCheck.Enabled = True 
 
            container.Controls.Add(gridCheck)  
            container.Controls.Add(gridLabel)  
 
        End Sub  
 
        Sub GridCheck_DataBinding(ByVal sender As Object, ByVal e As EventArgs)  
            Dim cBox As CheckBox = DirectCast(sender, CheckBox)  
            Dim container As GridDataItem = DirectCast(cBox.NamingContainer, GridDataItem)  
            If DirectCast(container.DataItem, DataRowView)("ContractObjectiveID").ToString <> "0" Then  
                cBox.Checked = True 
            Else  
                cBox.Checked = False 
            End If  
        End Sub  
 
        Public Sub gridLabel_DataBinding(ByVal sender As Object, ByVal e As EventArgs)  
            Dim l As Label = DirectCast(sender, Label)  
            Dim container As GridDataItem = DirectCast(l.NamingContainer, GridDataItem)  
            l.ID = "Label1" 
            l.Text = (DirectCast(container.DataItem, DataRowView))("ObjectiveCode").ToString()  
 
            Dim t As Telerik.Web.UI.RadToolTip = New Telerik.Web.UI.RadToolTip  
            t.Text = (DirectCast(container.DataItem, DataRowView))("Description").ToString()  
            t.Position = ToolTipPosition.MiddleRight  
            t.RelativeTo = ToolTipRelativeDisplay.Element  
            t.TargetControlID = l.ID  
 
        End Sub 


I do not get an error but at the same time I don not get the tooltip to show.  I need to be able to change the grid based on a field in the database.  I have the grid created but need to add the tooltip.  Is this possible?

3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 22 Apr 2009, 01:05 PM
Hello Eric,

In my opinion you forgot to add the RadToolTip to the Label's controls collection.

Regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Eric
Top achievements
Rank 1
answered on 22 Apr 2009, 02:20 PM
What exactly do you mean by  "add the RadToolTip to the Label's controls collection"?  When I tried l.controls.add(t) the lables no longer displays
0
Daniel
Telerik team
answered on 27 Apr 2009, 08:34 AM
Hello Eric,

Actually I meant the container's collection, and not the label's - apologies for the mistake.
For a convenience I created a sample which illustrates this approach.

Hope it will be suitable for your scenario.

Regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Eric
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Eric
Top achievements
Rank 1
Share this question
or