How to create gridviewtemplate dynamically in winforms?
The sample code below is with statically created gridviewtemplate, how to make it dynamically with 'n' number of gridviewtemplate from code?
radGridView1.DataSource = dt;
GridViewTemplate firstChildtemplate = new GridViewTemplate();
firstChildtemplate.DataSource = dt1;
radGridView1.MasterTemplate.Templates.Add(firstChildtemplate);
GridViewRelation relation = new GridViewRelation(radGridView1.MasterTemplate);
relation.ChildTemplate = firstChildtemplate;
relation.RelationName = "HeaderDetails";
relation.ParentColumnNames.Add("HeaderID");
relation.ChildColumnNames.Add("ParentHeaderID");
radGridView1.Relations.Add(relation);
GridViewTemplate secondChildtemplate = new GridViewTemplate();
secondChildtemplate.DataSource = dt2;
firstChildtemplate.Templates.Add(secondChildtemplate);
GridViewRelation relation2 = new GridViewRelation(firstChildtemplate);
relation2.ChildTemplate = secondChildtemplate;
relation2.RelationName = "CAPFieldDetails";
relation2.ParentColumnNames.Add("HeaderID");
relation2.ChildColumnNames.Add("ParentHeaderID");
radGridView1.Relations.Add(relation2);
The sample code below is with statically created gridviewtemplate, how to make it dynamically with 'n' number of gridviewtemplate from code?
radGridView1.DataSource = dt;
GridViewTemplate firstChildtemplate = new GridViewTemplate();
firstChildtemplate.DataSource = dt1;
radGridView1.MasterTemplate.Templates.Add(firstChildtemplate);
GridViewRelation relation = new GridViewRelation(radGridView1.MasterTemplate);
relation.ChildTemplate = firstChildtemplate;
relation.RelationName = "HeaderDetails";
relation.ParentColumnNames.Add("HeaderID");
relation.ChildColumnNames.Add("ParentHeaderID");
radGridView1.Relations.Add(relation);
GridViewTemplate secondChildtemplate = new GridViewTemplate();
secondChildtemplate.DataSource = dt2;
firstChildtemplate.Templates.Add(secondChildtemplate);
GridViewRelation relation2 = new GridViewRelation(firstChildtemplate);
relation2.ChildTemplate = secondChildtemplate;
relation2.RelationName = "CAPFieldDetails";
relation2.ParentColumnNames.Add("HeaderID");
relation2.ChildColumnNames.Add("ParentHeaderID");
radGridView1.Relations.Add(relation2);