Checkout the following link to online demo which demonstrates how to programmatically build hierarchical structures
with Telerik RadGrid. Creating Hierarchy Programmatically
You can also refer the section "Creating hierarchical grid programatically" in the help documentation. Programmatic creation