asp.net Hierarchical Data
| Introduction | |||||||
| A Hierarchical Data is a data that is organized in a tree-like structure and structure allows information to be stored in a parent-child relationship with one-to-many relation records. This data can be stored either in a single table or different database tables with a parent-child relationship using foreign key. | |||||||
|
|||||||
|
|||||||
| Setup the Repeater Control: In the aspx page, drag and drop a Repeater control, then go to the html source of this page, add the ItemTemplate in between the Repeater tag, then add an Asp.Net Table control from the toolbox. |
|||||||
|
|||||||
|
Setup the Code-Behind: The code-behind for this concept needs some attention, as it explains you the way to display the data in the database in a Hierarchical or tree-like structure. Let us go step by step. Step 1: Add the SqlClient namespace in the code-behind
Step 2: In the Page_Load event, you have to retrieve the
Step 3: Add the DataTable to a DataSet to add relationship
Step 4: Now create two DataColumn objects, one for Primary
Step 5:
Step 6: Very Important, we need this DataRelation object
Step 7: Finally, we need to add this relationship to the
|
|||||||
|
|||||||
|
|||||||
|
The above method GetChildObjects, has two parameters, the first one is the array of DataRow and the second is the “ref” DataTable which is going to have the records. Please note the “ref” keyword before the parameter declaration. This DataTable is responsible to hold the records to binding. Inside this method, we loop through the records of the DataRow arrays and we import record by record to the “ref” DataTable. Then again we call the same method GetChildObjects, to loop through its child rows. If there is no child rows, then execution will be stopped and no further call to this method will be made. Now, we are going to write another method to kick off the GetChildObjects methods, |
|||||||
|
|||||||
|
|||||||
|
Step 8: The last step in the Page_Load event, is to bind the Repeater control by calling the GetParentObjects as follows. Note that the argument passed to the GetParentObjects method is the DataSet’s first Table, not the DataTable object. |
|||||||
The complete code of the Page_Load event is as follows,
Setup Asp.Net Table Control to display the Hierarchy structure |
|||||||
The above code is simple as its need no detail explanation. First we find the Table
Now save all and press the “F5” button, the browser will popup, you can see the |
asp.net Hierarchical Data的更多相关文章
- mysql 树形数据,层级数据Managing Hierarchical Data in MySQL
原文:http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/ 引言 大多数用户都曾在数据库中处理过分层数据(hiera ...
- Managing Hierarchical Data in MySQL
Managing Hierarchical Data in MySQL Introduction Most users at one time or another have dealt with h ...
- 自定义 ASP.NET Identity Data Model with EF
One of the first issues you will likely encounter when getting started with ASP.NET Identity centers ...
- Managing Hierarchical Data in MySQL(邻接表模型)[转载]
原文在:http://dev.mysql.com/tech-resources/articles/hierarchical-data.html 来源: http://www.cnblogs.com/p ...
- 基于ASP.NET Core Data Protection生成验证token
ASP.NET Core Data Protection 不仅提供了非对称加密能力,而且提供了灵活的秘钥存储方式以及一致的加解密接口(Protect与Unprotect).Session中用到了它,C ...
- Hierarchical data in postgres
https://coderwall.com/p/whf3-a/hierarchical-data-in-postgres --------------------------------------- ...
- 集群环境下,你不得不注意的ASP.NET Core Data Protection 机制
引言 最近线上环境遇到一个问题,就是ASP.NET Core Web应用在单个容器使用正常,扩展多个容器无法访问的问题.查看容器日志,发现以下异常: System.Security.Cryptogra ...
- CS0016: 未能写入输出文件“c:\windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\data\34aae060\b7daa87d\App_Web_addadvice.aspx.cdcab7d2.ekhlcbjd.dll”--“目录名无效。 ”
产生原因: 应用程序运行时产生的临时文件需要存放到c:"windows"temp 文件夹下 而运行基于microsoft .net framework 框架下的应用程序 需要对te ...
- ASP.NET Core 数据保护(Data Protection 集群场景)【下】
前言 接[中篇],在有一些场景下,我们需要对 ASP.NET Core 的加密方法进行扩展,来适应我们的需求,这个时候就需要使用到了一些 Core 提供的高级的功能. 本文还列举了在集群场景下,有时候 ...
随机推荐
- JSON.parse: expected property name or '}'
早上被这问题坑了一个小时有了.后台返回的json如下,一切正常,但是手动把下面的json复制到js代码中,一直提示“ JSON.parse: expected property name or '}' ...
- 射频识别技术漫谈(7)——ID卡【worldsing笔记】
ID(Identification)是识别的意思,ID卡就是识别卡.ID卡包含范围广泛,只要具有识别功能的卡片都可以叫ID卡,例如条码卡,磁卡都可以是ID卡,我们这儿说的当然是射频识别卡. 射频ID卡 ...
- 按要求编写一个Java应用程序: (1)定义一个类,描述一个矩形,包含有长、宽两种属性,和计算面积方法。 (2)编写一个类,继承自矩形类,同时该类描述长方体,具有长、宽、高属性, 和计算体积的方法。 (3)编写一个测试类,对以上两个类进行测试,创建一个长方体,定义其长、 宽、高,输出其底面积和体积。
package jvxing; public class Jvxing { //成员变量 private double width; private double chang; public doub ...
- JavaScript(十一) HTML DOM - 改变CSS
HTML DOM 允许 JavaScript 改变 HTML 元素的样式. A.改变 HTML 样式 如需改变 HTML 元素的样式,请使用这个语法: document.getElementById( ...
- mysql之存储引擎
1.存储引擎概念 打比方说:一部电影有mp4,wmv,avi,flv...等格式.同样的一部电影在硬盘上有不同的存储格式,所占的空间与清晰程度也各不一样. 那么我们表里的数据存储在硬盘上,是如何存储的 ...
- fb设置viewSourceURL
- Android手机监控软件设计实现
一.需求分析: 随着IT信息技术的飞速发展,手机的普及,伴随着智能手机的出现及快速的更新换代,手机已不仅仅是一个通信工具,更是一个多功能的应用平台. 手机监控软件则是基于电脑监控软件的原理,植入手机平 ...
- WIX在VS2012中如何制作中文安装包
WIX安装图文并茂简易说明一文中介绍了WIX安装包的制作过程,不过生成的是英文版的,如果需要制作中文版的安装包呢? 方法很简单,只需要两步. 1.增加中文UI的文件WixUI_zh-cn.wxl到工程 ...
- iOS开发——网络编程OC篇&GCDAsyncSocket编程
GCDAsyncSocket编程 同上一篇文章一样,这里也是使用Socket实现一个聊天室,但是这里使用的是一个常用的框架实现的:GCDAsyncSocket 一:导入这个框架 二:声明这个Socke ...
- 会话跟踪session cookie
会话跟踪 会话(Session)跟踪是Web程序中常用的技术,用来跟踪用户的整个会话.常用的会话跟踪技术Cookie与Session.Cookie通过在客户端记录信息确定用户身份,Session通过在 ...
