我正在使用DNN并且(在同事的帮助下)创建了一个脚本来打印Form and List模块中的项目,但是需要将输出限制为三个。但是,该脚本不返回任何内容。谁能指出我可能出错的地方?
@using System.Data;
@using DotNetNuke.Entities.Modules;
@using DotNetNuke.Entities.Portals;
@using DotNetNuke.Modules.UserDefinedTable;
@using DotNetNuke.Entities.Users;
@{
var mc = new ModuleController();
var tc = new DotNetNuke.Entities.Tabs.TabController();
int portalId = PortalController.GetCurrentPortalSettings().PortalId;
var flModule = mc.GetModuleByDefinition(portalId, "Form and List");
int moduleId = -1;
int tabId = -1;
var tab = tc.GetTabByName("News", portalId);
if (tab != null) {
tabId = tab.TabID;
}
if (flModule != null) {
moduleId = 968;
}
var ds = (new UserDefinedTableController(moduleId, tabId, new UserInfo())).GetDataSet(true);
}
<ul>
@for (int i = 0; i < 3; i++)
{
DataRow row = ds.Tables["Data"].Rows[i];
<li>
<a href='/news#@row["UserDefinedRowId"]' title='@row["Title"]'>@row["Title"]</a>
</li>
}
</ul>