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

Getting controls inside EditFormTemplate

4 Answers 99 Views
Grid
This is a migrated thread and some comments may be shown as answers.
sameer
Top achievements
Rank 1
sameer asked on 20 Oct 2008, 07:09 AM
Hi Guys,

I have used a RadGrid and trying figure out as to how do i get a reference to the controls in the edit form template.
What i want is when i click the edit button of the RadGrid then on EditCommand event or any other event get the DataKeyValue for the row whose edit is clicked and then get data from database based on that Key and populate the values inside the Edit form template with the Values returned.

If i don't use EditCommand then i can set Values like this:

Now the values in the textbox can be set through
<asp:TextBox ID="txtName" runat="server" Text="<%# Bind('Name') %>" Width="300px"></asp:TextBox> 

but how do i set value based on idex to this field
<asp:RadioButtonList ID="Rblpagetype" runat="server"
                                                                    <asp:ListItem>Company1</asp:ListItem> 
                                                                    <asp:ListItem>Company2</asp:ListItem> 
                                                                    <asp:ListItem>Company3</asp:ListItem> 
                                                                </asp:RadioButtonList> 

As i am not able to figure out how to do this I thought of using the EditCommand event or any other event but unable to get reference to this controls to set there Values..

Hope you guys getting me.. please reply soon..

Thanx

4 Answers, 1 is accepted

Sort by
0
Missing User
answered on 20 Oct 2008, 07:38 AM
Hello sameer,


To see more information on the requested functionality, please refer to the following help article:


Greetings,
Plamen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
sameer
Top achievements
Rank 1
answered on 20 Oct 2008, 09:51 AM
Hi,

I think you did not understand my question.

What link you have given has control in the Grid Columns and referenceing on ItemCreated event. My situation is :
I have design a Edit Form template which is dispayed when i click edit button on the Grid.. Its a Pop up control. The design is as below

<EditFormSettings>  
<PopUpSettings ScrollBars="Vertical" Width="520px" ZIndex="9000" Modal="true" />  
   <FormTemplate>  
     <table id="Table2" cellspacing="2" cellpadding="1" width="100%" border="0" rules="none" style="border-collapse: collapse; margin: 10px;">  
        <tr>  
           <td colspan="2">  
               <div class="heading">General</div>  
           </td>  
         </tr>  
         <tr>  
            <td>  
               Name*(?)  
            </td>  
            <td>  
                <asp:TextBox ID="txtName" Text="<%# Bind('Name') %>" runat="server" Width="300px"></asp:TextBox> 
            </td>  
          </tr>  
          <tr> 
             <td> 
             Select Company(?) 
             </td> 
             <td> 
                 <asp:RadioButtonList ID="Rblcompany" runat="server"
                     <asp:ListItem>Company1</asp:ListItem> 
                     <asp:ListItem>Company2</asp:ListItem> 
                     <asp:ListItem>Company3</asp:ListItem> 
              </asp:RadioButtonList> 
              </td> 
           </tr> 
      <table>  
   </FormTemplate>  
</EditFormSettings>  

Now this is Edit Form Template. So when the user clicks the edit button i want to take the data in that Grid row and in fill this above control with that particular rows data.
As you can see i have put  Text="<%# Bind('Name') %>"
for TextBox control but how do i set the data for RadiobuttonList ?
As to how should i check one of them based on the data...?
I think this can be done on server side with OnEditCommand event but then how to reference this above controls so as to bind the data with them ?

Thanx





0
sameer
Top achievements
Rank 1
answered on 20 Oct 2008, 02:15 PM
Hi Guys,

guys i need the answer really urgently. Please help me out

thanx
0
Princy
Top achievements
Rank 2
answered on 21 Oct 2008, 04:57 AM
Hello Sameer,

You can try out the following code to access the RadioButtonList in the EditFormTemplate and then bind it as required.
cs:
 protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridEditFormItem && e.Item.IsInEditMode) 
        { 
            GridEditFormItem item = (GridEditFormItem)e.Item; 
            RadioButtonList rdbtnlist = (RadioButtonList)item.FindControl("Rblcompany"); 
            //code to bind the radiobuttonlist goes here 
        } 
    } 

Thanks
Princy.
Tags
Grid
Asked by
sameer
Top achievements
Rank 1
Answers by
Missing User
sameer
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or