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 提供的高级的功能. 本文还列举了在集群场景下,有时候 ...
随机推荐
- JavaAPI之Runtime类以及bat文件开启应用程序
package OtherToolsClass; import java.io.IOException; public class RuntimeDemo { /** * @param args */ ...
- Android实例-解决虚拟键盘遮挡问题(XE8+小米2)
结果: 1.可以自动向上移动,来防遮挡,但同时发现个问题,如果是按硬件返回没有问题,要是点输入法(QQ.百度输入法)上的隐藏就不行了. 2.点击Edit2后出现输入法,点输入法上的隐藏后, 再点Edi ...
- .Net 项目常见疑难杂症
1.A项目引用 B项目 B项目引用C.dll 同时 A也必须引用 C.dll 则 A中引用的C的版本 必须和 B中引用C的版本相同 否则就会出现下面这类问题:解决办法 :同步A B项目中引用C的版本一 ...
- CentOS6.5安装telnet
原文地址:http://www.cnblogs.com/zhongshengzhen/ 1.检查是否已经安装telnet [root@localhost ~]# rpm -qa | grep teln ...
- FormsAuthentication.GetRedirectUrl 方法
https://msdn.microsoft.com/zh-cn/library/8a22t5t3(v=vs.80) FormsAuthentication.GetRedirectUrl 方法 .NE ...
- 怎样在Java中实现基本数据类型与字符之间的转换
摘要:在我们对Java的学习当中数据类型之间的转换,是我们常见的事,我们也都知道基本数据类型之间有自动转换和强制转换,在int . short . long .float .double之间的转 ...
- Android事件分发原理
终于用上了word 2013来写博客,感觉真是老好了,以前在网页上写,老是要把网页拖上拖下的,每次都要吐一升老血啊,现在用上本地的word,瞬间感觉好多了.还有感谢为word写插件的这个大神,代码高亮 ...
- android studio 更改背景和设置字体大小
1,设置字体大小 2,设置背景主题
- jqueryui.position.js源代码分析
近期要写前端组件了.狂砍各种组件源代码,这里分析一款jqueryui中的posistion插件,注意,它不是jqueryui widget,首先看下源代码整体结构图 1.看到$.fn.position ...
- Retina屏下1px border
layout tltle tags post ios7下移动web开发的几个坑 webapp 1.Retina屏下1px border 由于高清屏的特性,1px是由2×2个像素点来渲染,那么我们样式上 ...