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

RadGrid editform FormTemplate data on demand or separate data source

1 Answer 167 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 17 Sep 2018, 07:43 PM

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

1 Answer, 1 is accepted

Sort by
0
Attila Antal
Telerik team
answered on 24 Sep 2018, 07:32 AM
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.
Tags
Grid
Asked by
Daniel
Top achievements
Rank 1
Answers by
Attila Antal
Telerik team
Share this question
or