asp.net - 分层网格

标签 asp.net

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

最佳答案

使 UltraWebGrid“分层”的一种方法是在数据集中建立数据关系并将数据集绑定(bind)到 UltraWebGrid。

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

首先,我们将建立 2 个数据集,并使用您喜欢的任何机制填充我们想要的数据。在本例中,我只是检索所有博客文章和所有评论。然后我们将作为子项的数据集“合并”到作为父项的数据集。最后,我们将在数据集中设置数据关系并将数据集绑定(bind)到 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查看我整理的示例。

希望这对您有所帮助,谢谢

关于asp.net - 分层网格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/594160/

相关文章:

javascript - 使用 Telerik Rad Controls 时的自动选项卡

asp.net - 从外部 Web 应用程序到多个 LDAP (AD) 提供商的 SSO

asp.net - 在 C# 中引用虚拟目录

asp.net - 在页面生命周期的 PreInit 事件中创建动态控件?

c# - 在中心制作更新进度面板

asp.net - 在 Asp.NET 中将 CSS 应用于内容页面

c# - 在自动页面刷新时,RadPanelBar 滚动上升

c# - 如何在 C# 中对类的 <list> 进行排序?

c# - Ipad 上传的图像显示在桌面所有浏览器中旋转 90 度在 asp.net c#

.net - 您可以为SVN推荐一个好的基于.NET Web的存储库浏览器吗?