DotNetNuke:GridView 与数据访问层不兼容?

发布于 2024-10-14 01:43:07 字数 1182 浏览 3 评论 0原文

我正在 C# 中开发 DotNetNuke 模块,为了降低复杂性,我选择尝试将模块的配置保留在一页中(标准设置模块除外)。我现在想知道这是多么明智的想法。

我的模块是一个简单的图像库,包含一张或多张图像。每个图像都有一个标题、一个图像源(url)和一个目标(另一个 url)。因此,我认为对于我的管理界面,我可以有一个简单的数据“网格”,您可以在其中编辑所有现有条目或添加新条目,所有这些都在同一页面上,有点像这样:

 Title              Image URL                           Anchor HREF
[A Picture!      ] [http://www.example.com/image.jpg ] [http://www.example.com]
[Another Picture!] [http://www.example.com/image2.jpg] [http://www.example.net]
[                ] [                                 ] [                      ]

浏览 WebControls,我找到了 GridView,乍一看它似乎就是我正在寻找的东西。然而,仔细观察它,我发现它需要直接绑定到数据源,而在数据访问层中执行操作的 DotNetNuke 标准似乎是创建一个数据对象的集合,如下所示

// EditDiscovery.ascx.cs
DiscoveryController objDiscoverys = new DiscoveryController();
List<DiscoveryInfo> lstDiscoveries = objDiscoverys.GetDiscoverys(ModuleId);

// DiscoveryController.cs
public List<DiscoveryInfo> GetDiscoverys(int ModuleId) {
    return CBO.FillCollection<DiscoveryInfo>(DataProvider.Instance().GetDiscoverys(ModuleId));
}

: GridView 缺少一些东西,或者我应该更改 GetDiscoverys 函数以返回 DataSet 而不是 DiscoveryInfo 对象列表?或者是否有更好的方法可以更好地与 DotNetNuke 的 DAL 保持一致?

I'm working on a DotNetNuke module in C#, and in order to cut down on the amount of complexity I have elected to try and keep the configuration of the module in one page (other than the standard Settings module). I now wonder how wise of an idea that is.

My module is a simple image gallery, with one or many images. Each image has a title, an image source (url) and a destination (another url). Therefore, I figured that for my admin interface, I could have a simple 'grid' of data where you can edit all of the existing entries or add a new one, all on the same page, sort of like this:

 Title              Image URL                           Anchor HREF
[A Picture!      ] [http://www.example.com/image.jpg ] [http://www.example.com]
[Another Picture!] [http://www.example.com/image2.jpg] [http://www.example.net]
[                ] [                                 ] [                      ]

Looking through WebControls, I found the GridView, which at first blush seemed like the sort of thing I was looking for. However, taking a closer gander at it, I found that it needed to be bound directly to a data source, while it seems like the DotNetNuke standard of doing things in the Data Access Layer is to create a collection of data objects like so:

// EditDiscovery.ascx.cs
DiscoveryController objDiscoverys = new DiscoveryController();
List<DiscoveryInfo> lstDiscoveries = objDiscoverys.GetDiscoverys(ModuleId);

// DiscoveryController.cs
public List<DiscoveryInfo> GetDiscoverys(int ModuleId) {
    return CBO.FillCollection<DiscoveryInfo>(DataProvider.Instance().GetDiscoverys(ModuleId));
}

Is there something I'm missing with the GridView, or should I be changing the GetDiscoverys function to return a DataSet as opposed to a List of DiscoveryInfo objects? Or is there a better approach that does things that align better with DotNetNuke's DAL?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

江湖彼岸 2024-10-21 01:43:07

您应该能够将 DiscoveryInfo 对象列表设置到网格。

MyGrid.DataSource = lstDiscoveries;
MyGrid.DataBind();

You should be able to set the list of DiscoveryInfo objects to the grid.

MyGrid.DataSource = lstDiscoveries;
MyGrid.DataBind();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文