RazorScript计数不起作用

时间:2014-02-24 15:55:54

标签: razor dotnetnuke

我正在使用DNN并且(在同事的帮助下)创建了一个脚本来打印Form and List模块中的项目,但是需要将输出限制为三个。但是,该脚本不返回任何内容。谁能指出我可能出错的地方?

http://jsfiddle.net/VsF6c/

@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>

0 个答案:

没有答案