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);
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);