ASP.NET List Methods for Active Database Links

  • 2021-06-29 10:48:28
  • OfStack

This article provides an example of how ASP.NET lists active links to databases.Share it for your reference.Specific analysis is as follows:

The active links to the database are listed here.Create a link to a generic list, mainly using the geeric list and a store, and if they are active, they will be displayed in the navigation.


//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>

I hope that the description in this paper will be helpful to everyone's asp.net program design.


Related articles: