Get values of FormTemplate to EditFormSettings

2 posts, 0 answers
  1. Erick
    Erick avatar
    1 posts
    Member since:
    May 2019

    Posted 11 Jun Link to this post

    How is the best way to get values of controls to EditFormSettings ?

    I have this code but I don't know if there's other best way:

     

    protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
           {
               if (e.CommandName == "PerformInsert")
               {
                   GridEditFormInsertItem editform = (GridEditFormInsertItem)((Telerik.Web.UI.GridEditFormInsertItem)(e.Item));
                   RadTextBox txtbx = (RadTextBox)editform.FindControl("txtName");
                   string strtxt = txtbx.Text;
               }
           }
    <EditFormSettings EditFormType="Template">
         <FormTemplate>
               <telerik:RadLabel runat="server" Text="Name:" Font-Bold="True"></telerik:RadLabel>
               <br />
               <telerik:RadTextBox ID="txtName" runat="server" InputType="Text" MaxLength="70" Width="100%" AutoCompleteType="None" autocomplete="off"></telerik:RadTextBox>
               <asp:RequiredFieldValidator ErrorMessage="*" ControlToValidate="txtName" runat="server" CssClass="rfv" />
               <telerik:RadButton ID="btnSave" runat="server" Text='<%# (Container is GridEditFormInsertItem) ? "Save" : "Update" %>'CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'> </telerik:RadButton>
         </FormTemplate>
    </EditFormSettings>

     

  2. Eyup
    Admin
    Eyup avatar
    3796 posts

    Posted 14 Jun Link to this post

    Hello Erick,

    Yes, this approach is correct by general:
    https://docs.telerik.com/devtools/aspnet-ajax/controls/grid/data-editing/database-level-editing

    You can also use the Bind expression in the mark-up code and then extract the values using ExtractValues method:
    -  https://demos.telerik.com/aspnet-ajax/grid/examples/data-editing/manual-crud-operations/defaultcs.aspx
    -  https://demos.telerik.com/aspnet-ajax/grid/examples/data-editing/form-template-update/defaultcs.aspx

    I hope this will prove helpful.

    Regards,
    Eyup
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top