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

所属分类: 网络编程 / ASP.NET 阅读数: 1950
收藏 0 赞 0 分享

本文实例讲述了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程序设计有所帮助。

更多精彩内容其他人还在看

用ASP.Net实现文件的在线压缩和解压缩

用ASP.Net实现文件的在线压缩和解压缩
收藏 0 赞 0 分享

ASP.NET中文件上传下载方法集合

ASP.NET中文件上传下载方法集合
收藏 0 赞 0 分享

ASP.NET通过Remoting service上传文件

ASP.NET通过Remoting service上传文件
收藏 0 赞 0 分享

ASP.NET2.0服务器控件之Render方法

ASP.NET2.0服务器控件之Render方法
收藏 0 赞 0 分享

ASP.NET2.0 WebRource,开发微调按钮控件

ASP.NET2.0 WebRource,开发微调按钮控件
收藏 0 赞 0 分享

ASP.NET2.0新特性概述

ASP.NET2.0新特性概述
收藏 0 赞 0 分享

介绍几个ASP.NET中容易忽略但却很重要的方法函数

介绍几个ASP.NET中容易忽略但却很重要的方法函数
收藏 0 赞 0 分享

asp.net2.0如何加密数据库联接字符串

asp.net2.0如何加密数据库联接字符串
收藏 0 赞 0 分享

用.NET 2.0压缩/解压功能处理大型数据

用.NET 2.0压缩/解压功能处理大型数据
收藏 0 赞 0 分享

ASP.NET入门随想之检票的老太太

ASP.NET入门随想之检票的老太太
收藏 0 赞 0 分享
查看更多