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

Getting the text from a textbox control in custom edit template

1 Answer 80 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Greg
Top achievements
Rank 1
Greg asked on 11 Feb 2009, 06:09 PM
Hello-

I have a RadGrid setup on my ASPX page with a custom edit template.  If add a new record or edit an existing record this custom template displays with a number of text boxes.  TextBox1, TexBox2, etc.  I want to take the text that was entered in one of the boxes TextBox1 for example and create a physical folder with that name (text from the textbox).

I'm not sure on a few things:

1. How do i get at a textbox control in a custom template?
2. I need to be able to do this on a New Record and Update Record.

The application is to take data entered by the user to describe a photo album.  I then want to create a physical folder in two locations, this will be for thumbnails and fullsize photos to be shown the enduser.

Thanks!

1 Answer, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 12 Feb 2009, 05:09 AM
Hello Greg,

You can try out the following code to access textboxes in a custom EditFormTemplate:
aspx:
 
  <EditFormSettings EditFormType="Template">  
        <FormTemplate>  
            <asp:TextBox ID="TextBox1" Text='<%#Bind("PlaceFrom") %>' runat="server"></asp:TextBox>  
             <asp:LinkButton ID="LinkButton1" CommandName="Update" runat="server">Update</asp:LinkButton> 
            <asp:LinkButton ID="LinkButton2"  CommandName="PerformInsert"  runat="server">Insert</asp:LinkButton> 
        </FormTemplate>  
        </EditFormSettings>  
 

cs:
protected void RadGrid1_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) 
    { 
 
        if (e.CommandName == RadGrid.PerformInsertCommandName || e.CommandName == RadGrid.UpdateCommandName) 
        { 
            if (e.Item is GridEditFormItem) 
            { 
                GridEditFormItem editItem = (GridEditFormItem)e.Item; 
                TextBox txtbx = (TextBox)editItem.FindControl("TextBox1"); 
 
            } 
        } 

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