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

Get a reference to a control within a FormTemplate?

2 Answers 145 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Software
Top achievements
Rank 1
Software asked on 25 Feb 2009, 12:21 AM
I have a RadGrid with an Edit Form FormTemplate.  I use it in PopUp mode when editing.  In the popup I want to set the value of several label controls on the form, but I can't get a reference to those label controls.  Is there a simple way to get a reference to those controls in the edit form template?
example:
<telerik:RadGrid...> 
<EditFormSettings ColumnNumber="3" CaptionFormatString="Edit Person ({0}) Details" 
    CaptionDataField="id" EditFormType="Template">  
    <EditColumn ButtonType="ImageButton" UniqueName="EditCommandColumn1">  
    </EditColumn> 
    <FormTemplate> 
        <table style="width:100%;">  
            <tr> 
                <td class="style1">  
                    id</td> 
                <td> 
                    <telerik:RadTextBox ID="tbId" Runat="server" EmptyMessage="id"   
                        Width="125px" OnTextChanged="tbId_TextChanged" AutoPostBack="true">  
                    </telerik:RadTextBox> 
                </td> 
            </tr> 
            <tr> 
                <td class="style1">  
                    name</td> 
                <td> 
                    <asp:Label runat="server" ID="lblName"></asp:Label> 
                </td> 
            </tr> 
        </table> 
    </FormTemplate> 
    <PopUpSettings Modal="True" ScrollBars="Auto" /> 
</EditFormSettings> 
</telerik:RadGrid> 
So I want the method "tvId_TextChanged" to trigger a db lookup that returns data and inserts it into the lblName control.

Thanks for the help!

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 25 Feb 2009, 03:45 AM
Hi Eddie,

You can use the naming container property to access the GridEditForm which contains the RadTextBox and thereby access the label in the EditForm. Check out the code below:
cs:
 protected void tbId_TextChanged(object sender, EventArgs e) 
    { 
        //code for dblook up 
        RadTextBox txtbx = (RadTextBox)sender; 
        GridEditFormItem editFormItem = (GridEditFormItem)txtbx.NamingContainer; 
        Label lbl = (Label)editFormItem.FindControl("lblName"); 
 
    } 

Thanks
Princy.
0
Software
Top achievements
Rank 1
answered on 25 Feb 2009, 04:17 PM
Thanks Princy, worked great!
Tags
Grid
Asked by
Software
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Software
Top achievements
Rank 1
Share this question
or