Hierarchical data gridview asp.net c#

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)

<%@ 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 id="form1" runat="server">
   
    <div>
    <asp:GridView ID="GridView1" runat="server">
    </asp:GridView>
    </div>
    </form>
</body>
</html>

        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();
mikezx10Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

G0ggyCommented:
The GridView does not display hierarchical data, however you can bind a master table and child tables in a relationship and allow the child table to show records on change of record in the parent table. Wrap this in an Ajax panel with an in memory DataTable (as long as you data isn't too large) and you have a similar thing.
0
abhilekhaCommented:
what you can do is create a datalist or gridview and have a datalist in it as an item, and have a link button with text "+" on each row, on click on + you can find that row datalist and bind it. which makes it looks like hierarchical data.
<asp:DataList ID="lsMaster" runat="server" Width="899px" OnItemDataBound="Item_Bound"
OnSelectedIndexChanged="ExpandProductList" DataKeyField="id" OnItemCommand="lsPrevious_Command">
<ItemTemplate>
<div>
    <asp:LinkButton ID="lnkPlus" runat="server" Text="+" Font-Size="X-Large" ToolTip="Expand Detail" ></asp:LinkButton>
</div>

<div>
<asp:DataList ID="lsChild" runat="server" OnItemDataBound="ProductItem_Bound" ItemStyle-Wrap="false"
  Width="95%">
  <ItemTemplate>
       <asp:Label ID="lblName" runat="server" ></asp:Label>
   </ItemTemplate>
</asp:DataList>

</div>
</asp:DataList>

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
G0ggyCommented:
0
mikezx10Author Commented:
Great thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.