分层网格 [英] hierarchical grid

查看:244
本文介绍了分层网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能帮助我如何使用C#创建在ASP.net分层Ultrawebgrid ......我很新的这...所以我需要一些基础知识和样本codeS .. u能帮助我吗?

Can anyone help me how to create a hierarchical Ultrawebgrid in ASP.net using C#... I'm very new to this... So i need some basics and sample codes .. Can u help me ?

推荐答案

作出UltraWebGrid分层的一种方法是在数据集中,建立数据关系和数据绑定到UltraWebGrid。

One way to make an UltraWebGrid "Hierarchical" is to establish a data relation in a dataset and bind the dataset to the UltraWebGrid.

作为一个例子,假设我们有一个博客,我们要显示的博客文章作为父,然​​后每篇文章在分层UltraWebGrid儿童发表任何评论。父表被命名为BlogArticle,是由BlogArticleID键控和子表被命名为BlogComment,并包含一个BlogArticleID一栏作为外键为BlogArticle。

As an example, let's say we have a Blog and we want to show the Blog Articles as the parent and then any comments made to each article as children in a Hierarchical UltraWebGrid. The parent table is named "BlogArticle" and is keyed by "BlogArticleID" and the child table is named "BlogComment" and contains a "BlogArticleID" column as a foreign key to "BlogArticle".

首先,我们将建立2数据集和使用任何机制您preFER与我们想要的数据填充它们。在这种情况下我只是检索所有的博客文章和所有的评论。然后,我们将合并的数据集是要子成说是父数据集。最后,我们会设置数据集中的我们的数据关系,并绑定数据集到UltraWebGrid。

First we would establish 2 datasets and fill them using whatever mechanism you prefer with the data we want. In this case I am simply retrieving all the Blog Articles and all the Comments. Then we would "merge" the dataset that is to be the child into the dataset that is to the parent. Finally, we would set our data relationship in the dataset and bind the dataset to the UltraWebGrid.

code代表这个的一个例子是如下...

An example of the code for this is as follows...

DataSet dsBlogArticle = new DataSet();
DataSet dsBlogComment = new DataSet();
//
// Fill each dataset appropriately.   
//
// Set Table Names.  This is needed for the merge operation.
dsBlogArticle.Tables[0].TableName = "BlogArticle";
dsBlogComment.Tables[0].TableName = "BlogComment";
//
// Merge the Blog Comment dataset into the Blog Article dataset
// to create a single dataset object with two tables.
dsBlogArticle.Merge(dsBlogComment);  
//
// Define Hierarchical relationships in the Dataset.
DataRelation dr = new DataRelation(
   "BlogArticleToComments",
   dsBlogArticle.Tables["BlogArticle"].Columns["BlogArticleID"],
   dsBlogArticle.Tables["BlogComment"].Columns["BlogArticleID"],
   false);
dsBlogArticle.Relations.Add(dr);    
//
// Bind the dataset to the grid.
this.grdBlogArticle.DataSource = dsBlogArticle;
this.grdBlogArticle.DataBind();

该UltraWebGrid会自动处理创建基于建立在数据集中的数据关系的层次网格。要查看此code填充的UltraWebGrid可以去这里来查看我放在一起的例子

The UltraWebGrid will automatically handle creating the Hierarchical grid based on the Data Relationship that is established in the dataset. To see this code populate an UltraWebGrid you can go here to view an example that I put together.

我希望这可以帮助,谢谢

I hope this helps, Thanks

这篇关于分层网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆