This is a migrated thread and some comments may be shown as answers.

Hierarchy Problem

1 Answer 105 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Bill
Top achievements
Rank 1
Bill asked on 12 Mar 2009, 07:49 PM
I'm fairly new using Winforms gridview.  I'm trying to create a grid with a simple hierarchy relationship.  In the full auto mode it works fine. but when I try the manual bound mode I cannot make it work.  The child grid is not displayed at all.

Below is a snippet of code.  The commented out code is when I try the auto mode, so I don't believe there is anything wrong with the dataset.

Any help would be greatly appreciated.

                grdKitDetail.Relations.Clear();
                grdKitDetail.MasterGridViewTemplate.ChildGridViewTemplates.Clear();
                grdKitDetail.MasterGridViewTemplate.Columns.Clear();
                grdKitDetail.DataSource = null;
                grdKitDetail.AutoGenerateHierarchy = false;

                DataSet dataset = new DataSet();
                if (!Route._getKitDetail(ref dataset, masterid, kittypes)) { fstatus = false; goto PROC_EXIT; }

                dataset.Relations.Clear();
                dataset.Tables[0].TableName = "KitDetail"; dataset.Tables[1].TableName = "Inventory";
                dataset.Relations.Add("Inventory", new DataColumn[] { dataset.Tables["KitDetail"].Columns["DetailId"] },
                                                                        new DataColumn[] { dataset.Tables["Inventory"].Columns["DetailId"] });

                //grdKitDetail.AutoGenerateHierarchy = true;
                //grdKitDetail.DataMember = "KitDetail";
                //grdKitDetail.DataSource = dataset;
                //goto PROC_EXIT;

                grdKitDetail.DataSource = dataset.Tables["KitDetail"];

                GridViewTemplate childtemplate = new GridViewTemplate();
                childtemplate.DataSource = dataset.Tables["Inventory"];

                grdKitDetail.MasterGridViewTemplate.ChildGridViewTemplates.Add(childtemplate);

                GridViewRelation childrelation = new GridViewRelation(grdKitMaster.MasterGridViewTemplate);
                childrelation.ChildTemplate = childtemplate;
                childrelation.RelationName = "KitDetailInventory";
                childrelation.ParentColumnNames.Add("DetailId");
                childrelation.ChildColumnNames.Add("DetailId");
                grdKitDetail.Relations.Add(childrelation);

1 Answer, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 13 Mar 2009, 01:35 PM
Hello Bill,

Thank you for contacting us.

I am not sure where is the issue, when looking at your code. My suggestion would be to set the DataSource after setting the relations. If this doesn't help, please open a support ticket and send us your project. I will try to find a proper solution.

If you have any other questions, don't hesitate to write us.

Greetings,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
GridView
Asked by
Bill
Top achievements
Rank 1
Answers by
Jack
Telerik team
Share this question
or