分层网格

时间:2009-02-27 09:55:41

标签: asp.net

任何人都可以帮我解决如何使用C#在ASP.net中创建分层Ultrawebgrid ...我对此非常新...所以我需要一些基础知识和示例代码..你可以帮我吗?

2 个答案:

答案 0 :(得分:3)

使UltraWebGrid成为“Hierarchical”的一种方法是在数据集中建立数据关系并将数据集绑定到UltraWebGrid。

例如,假设我们有一个博客,我们希望将博客文章显示为父级,然后将任何对每篇文章的评论显示为Hierarchical UltraWebGrid中的子项。父表名为“BlogArticle”,并由“BlogArticleID”键入,子表名为“BlogComment”,并包含“BlogArticleID”列作为“BlogArticle”的外键。

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

此代码的示例如下......

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将根据数据集中建立的数据关系自动处理创建分层网格。要查看此代码填充UltraWebGrid,您可以go here查看我放在一起的示例。

我希望这有帮助,谢谢

答案 1 :(得分:0)

this您要找的是什么?