i am using the code given below to add a grid template .in this controls are
dgrdsubcategory -> RAD GRID
category is the table from database it returns
Please Reply at earliest
dgrdSubCategory.AutoGenerateHierarchy = true;
SqlDataAdapter sdaCatid = null;
DataSet dsCatid = new DataSet();
DataSet dsGrid = DBFunctions.FillRadDataGirdReturnDS("category where parentcatid IN (select catid from category where catname='" + TV1.SelectedNode.Text + "')", dgrdSubCategory);
for (int i = 0; i < dsGrid.Tables[0].Rows.Count; i++)
{
DataRow drow = dsGrid.Tables[0].Rows[i];
sdaCatid = FillDataset("category where parentcatid='" + drow["catid"] + "'");
sdaCatid.Fill(dsCatid);
}
int count = dsCatid.Tables[0].Rows.Count;
GridViewTemplate template = new GridViewTemplate();
template.DataSource = dsCatid.Tables[0];
dgrdSubCategory.MasterGridViewTemplate.ChildGridViewTemplates.Add(template);
GridViewRelation relation = new GridViewRelation(dgrdSubCategory.MasterTemplate);
relation.ChildTemplate = template;
relation.RelationName = "SubCategory";
relation.ParentColumnNames.Add("catid");
relation.ChildColumnNames.Add("catid");
dgrdSubCategory.Relations.Add(relation);
radGrid1.DataSource = template;
dgrdSubCategory.AutoGenerateHierarchy = true;
SqlDataAdapter sdaCatid = null;
DataSet dsCatid = new DataSet();
DataSet dsGrid = DBFunctions.FillRadDataGirdReturnDS("category where parentcatid IN (select catid from category where catname='" + TV1.SelectedNode.Text + "')", dgrdSubCategory);
for (int i = 0; i < dsGrid.Tables[0].Rows.Count; i++)
{
DataRow drow = dsGrid.Tables[0].Rows[i];
sdaCatid = FillDataset("category where parentcatid='" + drow["catid"] + "'");
sdaCatid.Fill(dsCatid);
}
int count = dsCatid.Tables[0].Rows.Count;
GridViewTemplate template = new GridViewTemplate();
template.DataSource = dsCatid.Tables[0];
dgrdSubCategory.MasterGridViewTemplate.ChildGridViewTemplates.Add(template);
GridViewRelation relation = new GridViewRelation(dgrdSubCategory.MasterTemplate);
relation.ChildTemplate = template;
relation.RelationName = "SubCategory";
relation.ParentColumnNames.Add("catid");
relation.ChildColumnNames.Add("catid");
dgrdSubCategory.Relations.Add(relation);
radGrid1.DataSource = template;
dgrdSubCategory.AutoGenerateHierarchy = true;
SqlDataAdapter sdaCatid = null;
DataSet dsCatid = new DataSet();
DataSet dsGrid = DBFunctions.FillRadDataGirdReturnDS("category where parentcatid IN (select catid from category where catname='" + TV1.SelectedNode.Text + "')", dgrdSubCategory);
for (int i = 0; i < dsGrid.Tables[0].Rows.Count; i++)
{
DataRow drow = dsGrid.Tables[0].Rows[i];
sdaCatid = FillDataset("category where parentcatid='" + drow["catid"] + "'");
sdaCatid.Fill(dsCatid);
}
int count = dsCatid.Tables[0].Rows.Count;
GridViewTemplate template = new GridViewTemplate();
template.DataSource = dsCatid.Tables[0];
dgrdSubCategory.MasterGridViewTemplate.ChildGridViewTemplates.Add(template);
GridViewRelation relation = new GridViewRelation(dgrdSubCategory.MasterTemplate);
relation.ChildTemplate = template;
relation.RelationName = "SubCategory";
relation.ParentColumnNames.Add("catid");
relation.ChildColumnNames.Add("catid");
dgrdSubCategory.Relations.Add(relation);
radGrid1.DataSource = template;
dgrdSubCategory.AutoGenerateHierarchy = true;
SqlDataAdapter sdaCatid = null;
DataSet dsCatid = new DataSet();
DataSet dsGrid = DBFunctions.FillRadDataGirdReturnDS("category where parentcatid IN (select catid from category where catname='" + TV1.SelectedNode.Text + "')", dgrdSubCategory);
for (int i = 0; i < dsGrid.Tables[0].Rows.Count; i++)
{
DataRow drow = dsGrid.Tables[0].Rows[i];
sdaCatid = FillDataset("category where parentcatid='" + drow["catid"] + "'");
sdaCatid.Fill(dsCatid);
}
int count = dsCatid.Tables[0].Rows.Count;
GridViewTemplate template = new GridViewTemplate();
template.DataSource = dsCatid.Tables[0];
dgrdSubCategory.MasterGridViewTemplate.ChildGridViewTemplates.Add(template);
GridViewRelation relation = new GridViewRelation(dgrdSubCategory.MasterTemplate);
relation.ChildTemplate = template;
relation.RelationName = "SubCategory";
relation.ParentColumnNames.Add("catid");
relation.ChildColumnNames.Add("catid");
dgrdSubCategory.Relations.Add(relation);
radGrid1.DataSource = template;
dgrdSubCategory.AutoGenerateHierarchy = true;
SqlDataAdapter sdaCatid = null;
DataSet dsCatid = new DataSet();
DataSet dsGrid = DBFunctions.FillRadDataGirdReturnDS("category where parentcatid IN (select catid from category where catname='" + TV1.SelectedNode.Text + "')", dgrdSubCategory);
for (int i = 0; i < dsGrid.Tables[0].Rows.Count; i++)
{
DataRow drow = dsGrid.Tables[0].Rows[i];
sdaCatid = FillDataset("category where parentcatid='" + drow["catid"] + "'");
sdaCatid.Fill(dsCatid);
}
int count = dsCatid.Tables[0].Rows.Count;
GridViewTemplate template = new GridViewTemplate();
template.DataSource = dsCatid.Tables[0];
dgrdSubCategory.MasterGridViewTemplate.ChildGridViewTemplates.Add(template);
GridViewRelation relation = new GridViewRelation(dgrdSubCategory.MasterTemplate);
relation.ChildTemplate = template;
relation.RelationName = "SubCategory";
relation.ParentColumnNames.Add("catid");
relation.ChildColumnNames.Add("catid");
dgrdSubCategory.Relations.Add(relation);
radGrid1.DataSource = template;
dgrdSubCategory.AutoGenerateHierarchy = true;
SqlDataAdapter sdaCatid = null;
DataSet dsCatid = new DataSet();
DataSet dsGrid = DBFunctions.FillRadDataGirdReturnDS("category where parentcatid IN (select catid from category where catname='" + TV1.SelectedNode.Text + "')", dgrdSubCategory);
for (int i = 0; i < dsGrid.Tables[0].Rows.Count; i++)
{
DataRow drow = dsGrid.Tables[0].Rows[i];
sdaCatid = FillDataset("category where parentcatid='" + drow["catid"] + "'");
sdaCatid.Fill(dsCatid);
}
int count = dsCatid.Tables[0].Rows.Count;
GridViewTemplate template = new GridViewTemplate();
template.DataSource = dsCatid.Tables[0];
dgrdSubCategory.MasterGridViewTemplate.ChildGridViewTemplates.Add(template);
GridViewRelation relation = new GridViewRelation(dgrdSubCategory.MasterTemplate);
relation.ChildTemplate = template;
relation.RelationName = "SubCategory";
relation.ParentColumnNames.Add("catid");
relation.ChildColumnNames.Add("catid");
dgrdSubCategory.Relations.Add(relation);
radGrid1.DataSource = template;