开发者

Representing hierarchical data using a DataGrid/GridView control

I do n开发者_开发百科ot have access to third party components on this project. I think I only have access to the built-in DataGrid and GridView controls.

Is there a good example for representing hierarchical data (inside a grid - Master /Details) in a built-in ASP.NET server control?

I am looking for an expand/collapse tree structure kind of implementation.


You're after the TreeView Server Control.

This is built into ASP.NET (System.Web.UI.WebControls).

Code sample from the Microsoft Reference (for static content):

<asp:TreeView ID="MyTreeView" Runat="server">
  <Nodes>
    <asp:TreeNode Value="Child1" Expanded="True" Text="1">
      <asp:TreeNode Value="Grandchild1" Text="A" />
      <asp:TreeNode Value="Grandchild2" Text="B" />
    </asp:TreeNode>
    <asp:TreeNode Value="Child2" Text="2" />
    <asp:TreeNode Value="Child3" Expanded="True" Text="3">
      <asp:TreeNode Value="Grandchild1" Text="A" />
    </asp:TreeNode>
  </Nodes>
</asp:TreeView>

You can also build a Treeview Dynamically.

There are good samples at MSDN for this.


Please go through this, though it is not having sample code, it helps you to get started.

Code is for Asp.net 2.0 and at that time Jquery was not that much popular so code uses JavaScript so you might want to change few things while implementing it. Adapt it as per your need.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜