2016-04-05 15 views
-2

我的控制器代码在网格文件中显示列表使用.NET MVC剃刀C#

public ActionResult Index() 
    { 
     DirectoryInfo dirInfo = new DirectoryInfo(@"C:\Users\Documents\New folder"); 
     List<FileInfo> files = dirInfo.GetFiles("*.pdf").ToList(); 
     return View(files); 
    } 

我ViewCode是

@model IEnumerable<FileInfo> 

@{ 
    ViewBag.Title = "Home Page"; 
} 

@foreach (FileInfo file in Model) 
{ 
    <li>@file.Name</li> 
    <li>@file.Extension</li> 
} 

在这里,我需要在一个网格一起显示文件的这些列表中的超链接作为图像。

任何建议都赞赏在此先感谢..

回答

1

您可以使用如下代码,但我建议使用任何jQuery库像jqGrid的电网..

<table class="grid"> 
    <tr> 
     <th>Name</th> 
     <th>Extension</th> 
     <th>Edit</th> 
    </tr> 
    @foreach (var item in Model) 
    { 

     <tr> 
      <td class="left">@item.Name</td> 
      <td class="left">@item.Extension</td> 
      <td> 
       <a href="@Url.Action("Edit", new { id = item.ID })"> 
        <img src="@Url.Content("~/Content/Images/Image.bmp")", alt="Edit" /></a> 
      </td> 
     </tr> 
    } 
</table>