RadGrid editform FormTemplate data on demand or separate data source

2 posts, 0 answers
  1. Daniel
    Daniel avatar
    2 posts
    Member since:
    Jan 2018

    Posted 17 Sep 2018 Link to this post

    I am looking for the most efficient way to load data outside of the main datasource control into the grid edit formTemplate. In the past I have loaded data for a asp gridview on the edit command and would use the findControl to bind to the child datasource. I do not see an example for the FormTemplate mode only for the GridTableView.DetailTables. Is this possible and is there an example on the correct way to do it?


    Thanks in advance

  2. Attila Antal
    Attila Antal avatar
    621 posts

    Posted 24 Sep 2018 Link to this post

    Hi Daniel,

    One good approach to bind data to controls inside the EditFormTemplate would be by using the ItemDataBound event of RadGrid. At this point, the being bound to the grid row is known and this data can be used to apply conditional formatting, binding data to child controls, etc... Unlike the ItemCreated event, ItemDataBound will only fire when data is bound to the grid. See Differences Between ItemCreated and ItemDataBound, also check out the list of Commands that invoke Rebind Implicitly

    When in ItemDataBound event, you can then try accessing the Controls inside the FormTemplate as described in the Accessing Cells and Rows article. Sometimes, you might want to run different logic, when inserting a new record and different when editing. Following the Distinguish Edit or Insert Mode article you can identify the edit mode and execute logics accordingly.

    The suggestions from above will help you get started. You can also check out the sample project attached which shows how to bind data to a ComboBox inside the EditFormTemplate. (assemblies are not included to keep the file size to minimum)

    I hope the suggestions will be helpful.

    Kind regards,
    Attila Antal
    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