天天看點

pageadmin CMS網站制作教程:附屬表資料清單調用文法

pageadmin CMS 網站建設

教程:附屬表資料清單調用文法

清單調用文法

Html.SubDataList(參數1,參數2,參數3,參數4)

參數說明:

pageadmin CMS網站制作教程:附屬表資料清單調用文法

注:第一個參數對象中必須定義Table或ParentTable/ParentField屬性。

參數1常用屬性:

pageadmin CMS網站制作教程:附屬表資料清單調用文法
執行個體1:讀取product_images附屬表的前10條資料

@foreach (var item in Html.SubDataList(new{Table="product_images",ParentId=1,ShowNumber=10}))
{
    <div class="item clearfix">
    ....字段讀取
    </div>
}           

執行個體2:用分頁方式讀取product_images附屬表的資料,每頁顯示10條資料。

@{

PageInfo pageInfo = new PageInfo()
{
    PageSize = 10,
    CurrentPage = (int)ViewBag.CurrentPage //擷取目前頁面頁碼,系統預設
};           

}

@foreach (var item in Html.SubDataList(new { ParentTable="product",ParentField="images",ParentId=1,OrderBy = "thedate desc" }, null, null, pageInfo))
{
    <div class="item">
    ....字段讀取
    </div>
}           

繼續閱讀