Hi all,
I'd like to display a hierarchical grid - Master/Detail (or parent/child if you will). I've created a dataset that contains the parent and child records. My dataset only returns columns I want to display...in other words, I don't want to "hard-code" columns in the HTML markup or in the code behind. I also DON"T want to use any object datasource controls (ie: SQLDataSourceControl). Simply, I want to bind and display whatever data is in the dataset directly to the grid control.
Can you please provide me with the grid HTML and code that will allow me to bind this dataset to a grid?
public static DataSet GetHierarchicalDataSet()
{
DataTable parentTable = GetParentData(); //retrieves parent data from database
parentTable.TableName = "Parent";
DataTable childTable = GetChildData(); //retrieves child data from database
childTable.TableName = "Child"
DataSet ds = new DataSet();
ds.Tables.Add(parentTable.Copy());
ds.Tables.Add(childTable.Copy());
DataColumn parentColumn = ds.Tables["Parent"].Columns["ParentID"];
DataColumn childColumn = ds.Tables["Child"].Columns["ParentID"];
DataRelation relationship = new DataRelation("ParentChild", parentColumn, childColumn);
ds.Relations.Add(relationship);
return ds;
}
I'd like to display a hierarchical grid - Master/Detail (or parent/child if you will). I've created a dataset that contains the parent and child records. My dataset only returns columns I want to display...in other words, I don't want to "hard-code" columns in the HTML markup or in the code behind. I also DON"T want to use any object datasource controls (ie: SQLDataSourceControl). Simply, I want to bind and display whatever data is in the dataset directly to the grid control.
Can you please provide me with the grid HTML and code that will allow me to bind this dataset to a grid?
public static DataSet GetHierarchicalDataSet()
{
DataTable parentTable = GetParentData(); //retrieves parent data from database
parentTable.TableName = "Parent";
DataTable childTable = GetChildData(); //retrieves child data from database
childTable.TableName = "Child"
DataSet ds = new DataSet();
ds.Tables.Add(parentTable.Copy());
ds.Tables.Add(childTable.Copy());
DataColumn parentColumn = ds.Tables["Parent"].Columns["ParentID"];
DataColumn childColumn = ds.Tables["Child"].Columns["ParentID"];
DataRelation relationship = new DataRelation("ParentChild", parentColumn, childColumn);
ds.Relations.Add(relationship);
return ds;
}