本文實例講述了ASP.NET列出數(shù)據(jù)庫活躍鏈接的方法。分享給大家供大家參考。具體分析如下:
這里列出數(shù)據(jù)庫的活躍鏈接。主要使用geeric列表和一個貯存器,創(chuàng)建一個泛型列表的鏈接,如果他們是活躍的,那么他們將顯示在導(dǎo)航了。
//First in C# where you create the controller action method //to create the method that will populate all content details //add the following code public ActionResult Details(int id) { var repositoryList = _repository.List(); ViewData["List"] = repositoryList; return View(_repository.Get(id)); } <!--now is ASP.net add the following in your navigation panel-> <ul> <% foreach (var item in (List<Service>)ViewData["List"]) {%> <% if ((item.isActive) || (item.id != 0)) { %><li><%=Html.ActionLink(item.Title, "Details", new { id = item.id })%></li><%} %> <%} %> </ul>
希望本文所述對大家的asp.net程序設(shè)計有所幫助。
聲明:本網(wǎng)頁內(nèi)容旨在傳播知識,若有侵權(quán)等問題請及時與本網(wǎng)聯(lián)系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com