ASP.NET列出数据库活跃链接的方法
本文实例讲述了ASP.NET列出数据库活跃链接的方法。分享给大家供大家参考。具体分析如下:
这里列出数据库的活跃链接。主要使用geeric列表和一个贮存器,创建一个泛型列表的链接,如果他们是活跃的,那么他们将显示在导航了。
//FirstinC#whereyoucreatethecontrolleractionmethod
//tocreatethemethodthatwillpopulateallcontentdetails
//addthefollowingcode
publicActionResultDetails(intid)
{
varrepositoryList=_repository.List();
ViewData["List"]=repositoryList;
returnView(_repository.Get(id));
}
<!--nowisASP.netaddthefollowinginyournavigationpanel->
<ul>
<%foreach(varitemin(List<Service>)ViewData["List"])
{%>
<%if((item.isActive)||(item.id!=0))
{%><li><%=Html.ActionLink(item.Title,"Details",new{id=item.id})%></li><%}%>
<%}%>
</ul>
希望本文所述对大家的asp.net程序设计有所帮助。
热门推荐
10 钢琴人祝福语女生简短
11 岗位考试顺利祝福语简短
12 关于老师蛋糕祝福语简短
13 娘家妈妈新婚祝福语简短
14 生日留言简短祝福语大全
15 祝福语诗意文案简短
16 校长退休文案祝福语简短
17 宝子生日祝福语简短
18 寒露祝福语毕业寄语简短