当前位置: 移动技术网 > IT编程>开发语言>.net > ASP.NET列出数据库活跃链接的方法

ASP.NET列出数据库活跃链接的方法

2017年12月12日  | 移动技术网IT编程  | 我要评论

热爱剧情介绍,劳拉失魂记,fsl

本文实例讲述了asp.net列出数据库活跃链接的方法。分享给大家供大家参考。具体分析如下:

这里列出数据库的活跃链接。主要使用geeric列表和一个贮存器,创建一个泛型列表的链接,如果他们是活跃的,那么他们将显示在导航了。

//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程序设计有所帮助。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网