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

FormTemplate: Setting Tooltip

2 Answers 48 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jeremy Yoder
Top achievements
Rank 1
Jeremy Yoder asked on 21 Jun 2010, 08:15 PM

When the user clicks edit on a line and it pops up my FormTemplate, I want to set the tooltip on a textbox, based on its value. In the ItemCreated event, I have the following...

If (TypeOf e.Item Is GridEditFormItem) AndAlso (e.Item.IsInEditMode) Then    
    Dim item As GridEditFormItem = CType(e.Item, GridEditFormItem)     
    Dim txtID As RadTextBox = CType(item.FindControl("txtID"), RadTextBox)     
    txtID.ToolTip = LookUpDesc(txtID.Text)    
End If 

The LookUpDesc function queries our DB to find the value. It would work, but txtID.Text has no value in this event, even though it does once the FormTemplate is up. Is there a different event I should use where txtID.Text would evaluate to the value? Or how can I make this work?

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 22 Jun 2010, 07:39 AM
 Hello Jeremy,

Since the ItemCreated event is fired before the item is data-bound , data will not avalilable in the cells' text or input controls. In ItemDataBound all is available. So you can try your code in ItemDataBound than ItemCreated.

Please refer the following documentation which explains the difference between ItemCreated and ItemDataBound events:
Distinguishing the major differences between ItemCreated and ItemDataBound events

VB.Net:
 
 Protected Sub RadGrid1_ItemDataBound(sender As Object, e As GridItemEventArgs) 
    If (TypeOf e.Item Is GridEditFormItem) AndAlso (e.Item.IsInEditMode) Then 
        Dim item As GridEditFormItem = DirectCast(e.Item, GridEditFormItem) 
        Dim txtID As RadTextBox = DirectCast(item.FindControl("txtID"), RadTextBox) 
        txtID.ToolTip = LookUpDesc(txtID.Text) 
    End If 
 End Sub 
 

Thanks,
Princy.
0
Jeremy Yoder
Top achievements
Rank 1
answered on 22 Jun 2010, 02:00 PM

Thanks much -- that did the trick!
Tags
Grid
Asked by
Jeremy Yoder
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Jeremy Yoder
Top achievements
Rank 1
Share this question
or