Hi,
There are three primary tasks when you want to create the Grid dynamically:
1. Dynamically creates the Grid object and all columns. This part is very standard and easy, and this part does not have much particular with the Grid. For example, if you would like to dynamically creates a Grid inside a Panel control, you would do:
Code: C#
EO.Web.Grid grid = new EO.Web.Grid();
Panel1.Controls.Add(grid);
This is exactly the same as dynamically creating any other controls. You can also dynamically creating columns and it will be something like this:
Code: C#
EO.Web.StaticColumn column = new EO.Web.StaticColumn();
grid.Columns.Add(column);
There isn't much special about this except that you need to pay attention to the column type. The above code uses "StaticColumn". There are many column types and you will need to choose the type that fits your need.
One thing that you need to pay extra attention is that once you dynamically load a control, you need to make sure it is also loaded during postback. Otherwise server side events will not work. This is a general ASP.NET coding rule, not just for the Grid;
2. Set the Grid's appearance. The above code will create the Grid for you, but it won't have any appearance settings. So once you dynamically creates the grid, you will also need to set its apparance/style properties. Our previous post mentioned that the easiest way is for you to have it configured property at design time, then try to duplicate the settings with code;
3. Populate the Grid. Till now you have dynamically created the Grid and it looks good. However it does not have any data, so it's empty. The next step is to populate it with data. This step has nothing to do with whether the Grid is dynamically created or not. Both the documentation and samples covered this part extensively. So if you are not familiar with this part, please go over the the documentation and samples first. I would also suggest you to try this part on a Grid created at design time because regardless whether the Grid is created at design time or not, this step is exactly the same;
Hope this gives you a better picture. Please feel free to let us know if you still have any questions.
Thanks!