SetDataSource is a new method used to bind a DataGrid to an array of objects during runtime.
c_Control5 is our example datagrid.
var c = form.GetControl("c_Control5").InputControl;
c.SetDataSource(data);
Let's analyze the above code in more detail:
var c = form.GetControl("c_Control5").InputControl;
The above segment finds our example datagrid and stores it in a variable. Normally we'd only have to use
var c = form.GetControl("c_Control5"); but in our case the SetDataSource command is under the InputControl property.
var data = [];
Declares an array called data which we'll use to store objects and finally binds it to the datagrid.
The above code segment creates a new object called item, declares two parameters called ID and Name and initializes them with values . data.push(item); stores the newly created object in the array.
c.SetDataSource(data);
Finally, we use SetDataSource to bind the array to our example's datagrid. The result of our actions is shown below: