Hierarchical data in gridview from dataset
Mar 27, 2010 10:49 AM|mikeasp30|LINK
I want to display child rows in the datagrid after the + sign is selected (like grouping & outlining in excel). This is automatic in infragistic grids but when i did in asp (no more infragistics) it doesnt work. here is my code (very simple stuff)
How To: Display Hierarchical Data with Row Details (RadGridView for Silverlight) July 30, 2009.NET 0 Comments The main goal of the Row Details feature is to let you present additional information about a row.
<%@ Page Language='C#' AutoEventWireup='true' CodeFile='Default.aspx.cs' Inherits='_Default' %>
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head runat='server'>
<title></title>
</head>
<body>
<form runat='server'>
<div>
<asp:GridView runat='server'>
</asp:GridView>
</div>
</form>
</body>
</html>
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head runat='server'>
<title></title>
</head>
<body>
<form runat='server'>
<div>
<asp:GridView runat='server'>
</asp:GridView>
</div>
</form>
</body>
</html>
![Hierarchical grid examples Hierarchical grid examples](/uploads/1/2/6/2/126205447/693277363.jpg)
DataSet ds = new DataSet();
ds.Tables.Add(myDataAccess.ExecuteSelectCommand('uspCategories'));
ds.Tables[0].TableName = 'tblCategories';
ds.Tables.Add(myDataAccess.ExecuteSelectCommand('uspProducts'));
ds.Tables[1].TableName = 'tblProducts';
DataRelation rel = new DataRelation('relation', ds.Tables[0].Columns['CategoryID'], ds.Tables[1].Columns['CategoryID']);
ds.Relations.Add(rel);
GridView1.DataSource = ds;
GridView1.DataBind();
ds.Tables.Add(myDataAccess.ExecuteSelectCommand('uspCategories'));
ds.Tables[0].TableName = 'tblCategories';
ds.Tables.Add(myDataAccess.ExecuteSelectCommand('uspProducts'));
ds.Tables[1].TableName = 'tblProducts';
DataRelation rel = new DataRelation('relation', ds.Tables[0].Columns['CategoryID'], ds.Tables[1].Columns['CategoryID']);
ds.Relations.Add(rel);
GridView1.DataSource = ds;
GridView1.DataBind();
Data Grid View Sort
- How To: Display Hierarchical Data with Row Details (RadGridView for Silverlight) July 30, 2009.NET 0 Comments The main goal of the Row Details feature is to let you present additional information about a row.
- To add and insert rows into the Kettic GridView, we need to use the Row collection to accomplish that. The following is a sample that shows how to add an empty row and enter a value to the existing columns by using the KetticGridView.AddNewRows() method.
- When using the DataGrid control, you can customize the data presentation by adding a row details section. Adding a row details section enables you to group some data in a template that is optionally visible or collapsed. For example, you can add row details to a DataGrid that presents only a summary.