Creating Hierarchical RadGrid via Code

Thread is closed for posting
2 posts, 0 answers
  1. Munish
    Munish avatar
    13 posts
    Member since:
    Jul 2012

    Posted 01 Jul 2012 Link to this post

    Hello Team,
    I am facing problem in dynamic creation grid structure and bind data and not able to see nested grid data below is code for same. Please do help me asap.

    Looking forward to your response.

    RadGridData.AutoGenerateColumns = false;

                //generate grid columns/ grid structure
                GridBoundColumn ZoneColumn;
                GridTableView gridTableView = new GridTableView();
                for (int ColumnCount = 0; ColumnCount < ZoneData.Tables[0].Columns.Count; ColumnCount++)
                    ZoneColumn = new GridBoundColumn();
                    ZoneColumn.DataField = Convert.ToString(ZoneData.Tables[0].Columns[ColumnCount]);
                    ZoneColumn.HeaderText = Convert.ToString(ZoneData.Tables[0].Columns[ColumnCount]);
                    ZoneColumn.UniqueName = Convert.ToString(ZoneData.Tables[0].Columns[ColumnCount]);
                    ZoneColumn.SortExpression = Convert.ToString(ZoneData.Tables[0].Columns[ColumnCount]);

                    gridTableView.AutoGenerateColumns = false;
                    for (int innerColumnCount = 0; innerColumnCount < ZoneData.Tables[1].Columns.Count; innerColumnCount++)
                        ZoneColumn = new GridBoundColumn();
                        ZoneColumn.DataField = Convert.ToString(ZoneData.Tables[1].Columns[innerColumnCount]);
                        ZoneColumn.HeaderText = Convert.ToString(ZoneData.Tables[1].Columns[innerColumnCount]);
                        ZoneColumn.UniqueName = Convert.ToString(ZoneData.Tables[1].Columns[innerColumnCount]);
                        ZoneColumn.SortExpression = Convert.ToString(ZoneData.Tables[1].Columns[innerColumnCount]);

                RadGridData.MasterTableView.AutoGenerateColumns = false;
                RadGridData.MasterTableView.DetailTables[0].AutoGenerateColumns = false;
                GridRelationFields relationFields = new GridRelationFields();
                relationFields.MasterKeyField = "ID";
                relationFields.DetailKeyField = "ID";

                RadGridData.MasterTableView.DataSource = ZoneData.Tables["Zone"]; //ZoneData is dataset with table data
                RadGridData.MasterTableView.DetailTables[0].DataSource = ZoneData.Tables["ZoneContract"];

    Thanks & Regards
  2. Radoslav
    Radoslav avatar
    1564 posts

    Posted 04 Jul 2012 Link to this post

    Hello Munish,

    Please check out the following resources: (Create hierarchical grid programmatically section)

    I hope this helps.

    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. DevCraft R3 2016 release webinar banner
Back to Top