My Controller code
public ActionResult Index()
{
DirectoryInfo dirInfo = new DirectoryInfo(@"C:\Users\Documents\New folder");
List<FileInfo> files = dirInfo.GetFiles("*.pdf").ToList();
return View(files);
}
My ViewCode is
@model IEnumerable<FileInfo>
@{
ViewBag.Title = "Home Page";
}
@foreach (FileInfo file in Model)
{
<li>@file.Name</li>
<li>@file.Extension</li>
}
Here I need to display these list of files in a grid along with its hyperlink as an image.
Any suggestions are appreciated thanks in advance..
You can use like below code but I suggest to use any jquery library for grid like 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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.