Hi Hrvoje,
Thanks for using Syncfusion products.
From your query we suspect that you are returning data from the select statement with different field and then bind it to the grid again.
If you are doing so then for your scenario there is no need to define the columns for the grid.
We can use the auto generated columns concept to display all the columns/fields from the assigned data source to the grid.
Whenever you want to change the data source then assign that data source to the DataSource property of the grid and call the DataBind method in code behind itself.
Refer to the below code example,
//Query processing for retrieving data from data base and select command with ifferent columns
. . . .
. . . .
Me.Grid1.DataSource = the data need to be bind to the grid
Me.Grid1.DataBind()
. . . .
. . . .
<ej:Grid ID="Grid1" runat='server' AllowPaging="true" AllowSorting="true" AllowResizeToFit="true">
//No need column definition
</ej:Grid> |
Refer to the below link for more clarification about auto generation,
If we are misunderstood your requirement please provide us below details to understand your requirement,
1. How would you like to change the data source whether in code behind or you want to pass data via any post?
2. Do you want to generate a list of columns and grid properties in code behind.
3. Explain your requirement clearly.
The provided information will help to analyze the issue and provide you the response as early as possible.
Regards,
Gowthami V.