ASP.NET列出數據庫活躍鏈接的方法
更新時間:2015年06月25日 09:29:44 作者:小卒過河
這篇文章主要介紹了ASP.NET列出數據庫活躍鏈接的方法,實例分析了asp.net列出數據庫活躍鏈接的原理與實現技巧,需要的朋友可以參考下
本文實例講述了ASP.NET列出數據庫活躍鏈接的方法。分享給大家供大家參考。具體分析如下:
這里列出數據庫的活躍鏈接。主要使用geeric列表和一個貯存器,創(chuàng)建一個泛型列表的鏈接,如果他們是活躍的,那么他們將顯示在導航了。
//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程序設計有所幫助。
相關文章
阿里云上從ASP.NET線程角度對“黑色30秒”問題的全新分析
在這篇博文中,我們拋開對阿里云的懷疑,完全從ASP.NET的角度進行分析,看能不能找到針對問題現象的更合理的解釋2015-09-09
動態(tài)加載用戶控件至DataList并為用戶控件賦值實例演示
本文借用使用通用的新聞例子演示動態(tài)加載用戶控件至DataList并為用戶控件賦值,感興趣的朋友可以了解下2013-01-01
在ASP.NET中用MSDNURLRewriting實現Url Rewriting
在ASP.NET中用MSDNURLRewriting實現Url Rewriting...2007-03-03

