Creating controls dynamically could become quite tricky as many things in ASP.NET AJAX depend on the Page's Lifecycle and ViewState. More specifically, creating RadGrid programmatically, must be done in specific events of the Page. For instance, the Init event would be the best, meaning that neither of the events such as ItemCommand, ItemCreated, ItemDataBound, etc.. are optimal for that. I advise checking out the following article that describes several scenarios for creating a grid dynamically: Creating a RadGrid Programmatically
Furthermore, the outcome depends very much on the DataBinding technique as well. For complex scenarios we recommend using the Advanced Data-binding (Using NeedDataSource Event)
, and in that case ensure that the DataBind() method is not being called anywhere in the code behind as it could cause unexpected behavior.
There are two ways for creating RadGrid hierarchy, either using DetailTables
or using NestedViewTemplate
. From the screenshot you have shared, I assume NestedViewTemplate
is used, is that correct?
I would also recommend checking out the Hierarchy load modes
article that might be helpful in your case. If the load mode is set to client, every child control of the grid is rendered at once, if its set to server, child controls get rendered when the Hierarchical item is getting expanded.
In any case, it would be very helpful if you could provide us more detail on the current configuration so that we can understand the structure, scenario and then we can advise you accordingly. The best would be if you could share the markup code and the code behind so that we can take a look.
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.