DotNetNuke: GridView incompatible with Data Access Layer?

只愿长相守 提交于 2019-12-12 06:15:50

问题


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?


回答1:


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

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


来源:https://stackoverflow.com/questions/4795173/dotnetnuke-gridview-incompatible-with-data-access-layer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!