The demo shows the two ways of server-side binding of RadDataForm
- Using declarative DataSource control by setting DataSourceID property - you can bind a DataForm to various data source controls such as SqlDataSource, ObjectDataSource, XmlDataSource, etc.
- Using the NeedDataSource event in the code-behind where the DataSource is specified - The key to the dynamic data binding of Telerik RadDataForm is handling correctly the NeedDataSource event. That's why we chose this exact name. 'Need' in this case actually means that if at an exact moment the data source property does not point to a valid data source object, the control will not behave correctly.
The advantages of using NeedDataSource
event are that the developer does not need to write any code in order to handle the logic about when and how the data-binding should be processed. In the code of the NeedDataSource
handler you should prepare the data source or custom list of objects for Telerik RadDataForm
and assign it to the controls's DataSource