Way to access FormTemplate fields from code-behind?

2 posts, 0 answers
  1. ToltingColtAcres
    ToltingColtAcres avatar
    83 posts
    Member since:
    Nov 2010

    Posted 01 Nov 2013 Link to this post

    Given the following code example, is there a way to access "RadTextBox_Name" in code-behind prior to initiating an Edit operation on the record? e.g. in the RadGrid onItemCommand event (CommandName="Edit") is there a way to manipulate the attributes of RadTextBox_Name prior to the pop-up appearing? My real-world application is a bit more complicated than this (e.g. I have several fields and want to have some enabled/disabled based on values in other fields, etc.) but for purposes of my question, the below code example is adequate.

    <telerik:RadGrid ID="RadGrid_Products" runat="server" AutoGenerateColumns="False" AllowAutomaticUpdates="True"  DataSourceID="SqlDataSource_Products">
    <MasterTableView DataKeyNames="Key" EditMode="PopUp" commanditemdisplay="Bottom" >
       <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn1" />
       <telerik:GridBoundColumn DataField="Key" HeaderText="Key" UniqueName="Key" />
       <telerik:GridBoundColumn DataField="Name" HeaderText="Name" UniqueName="Name" />
      <EditFormSettings EditColumn-UniqueName="EditCommandColumn1" EditFormType="Template" CaptionDataField="Name" >
         <table width="100%">
           <td width="10%" align="right">
           <td width="90%">
            <telerik:RadTextBox ID="RadTextBox_Name" runat="server" width="100%" Text='<%# Bind("Name" ) %>' />
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 03 Nov 2013 Link to this post

    Hi ,

    Please try the following code snippet to access the RadTextBox of EditForm in edit mode.

    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
        if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
            GridEditFormItem edit = (GridEditFormItem)e.Item;
            //Access 'RadTextBox_Name' RadTextBox in EditForm during Edit mode
            RadTextBox radtxt = (RadTextBox)edit.FindControl("RadTextBox_Name");           

  3. DevCraft R3 2016 release webinar banner
Back to Top