2016-03-20 3 views
-1

これは、コード一次マイグレーションを使用したEF6を使用したWebアプリケーションMVC4です。MVC4の列の整列Index.cshtml

私の列の配置に問題があります。私は、それぞれのタイトルをどこにしたいのかを示すために矢印を追加しました。 正しく整列させるためにどのコードを追加する必要がありますか?

enter image description here

Users \ユーザービューは、あなたのヘッダー行の途中で

<th></th> 

空のタグを持っているように見えますCreate.cshtml

@using PagedList; 
@using PagedList.Mvc; 
<link href="~/Content/PagedList.css" rel="stylesheet" type="text/css" /> 
@model IPagedList<RecreationalServicesTicketingSystem.Models.User> 

@{ 
    ViewBag.Title = "Users"; 
} 

<h2>Users</h2> 

<p> 
    @Html.ActionLink("Create New", "Create") 
</p> 
@using (Html.BeginForm("Index", "Users", FormMethod.Get)) 
{ 
    <p> 
     Find by name: @Html.TextBox("SearchString", ViewBag.CurrentFilter as string) 
     <input type="submit" value="Search" /> 
    </p> 
} 

<table> 
    <tr> 
     <th> 
      First Name 
     </th> 
     <th> 
      @Html.ActionLink("Last Name", "Index", new { sortOrder = ViewBag.NameSortParm }) 
     </th> 
     <th> 
      @Html.ActionLink("Enrollment Date", "Index", new { sortOrder = ViewBag.DateSortParm }) 
     </th> 
     <th></th> 

     <th> 
      Department ID 
     </th> 
     <th> 
      Depot ID 
     </th> 
     <th> 
      Is Administrator 

     </th> 
    </tr> 

@foreach (var item in Model) { 
    <tr> 
     <td> 
      @Html.DisplayFor(modelItem => item.FirstMidName) 
     </td> 
     <td> 
      @Html.DisplayFor(modelItem => item.LastName) 
     </td> 
     <td> 
      @Html.DisplayFor(modelItem => item.EnrollmentDate) 
     </td> 
     <td> 
      @Html.DisplayFor(modelItem => item.Department.DepartmentName) 
     </td> 
     <td> 
      @Html.DisplayFor(modelItem => item.Depot.DepotName) 
     </td> 
     <td> 
      @Html.DisplayFor(modelItem => item.IsAdministrator) 
     </td> 
     <td> 
      @Html.ActionLink("Edit", "Edit", new { id=item.UserID }) | 
      @Html.ActionLink("Details", "Details", new { id=item.UserID }) | 
      @Html.ActionLink("Delete", "Delete", new { id=item.UserID }) 
     </td> 
    </tr> 
} 

</table> 
Page @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) of @Model.PageCount 

@Html.PagedListPager(Model, page => Url.Action("Index", new { page, sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter })) 

答えて

0

あなたがthead要素とTBODYタグを使用する必要があります。

<table> 
     <thead> 
      <tr> 
       <th>/* Your column names*/ </th> 
       /* ... */ 
      </tr> 
     </thead> 
     <tbody> 
      /*... */ 
     </tbody> 
    </table> 
4

を\。 CRUDリンクがあるヘッダ行の最後に移動したいと思うかもしれません。

<tr> 
    <th> 
     First Name 
    </th> 
    <th> 
     @Html.ActionLink("Last Name", "Index", new { sortOrder = ViewBag.NameSortParm }) 
    </th> 
    <th> 
     @Html.ActionLink("Enrollment Date", "Index", new { sortOrder = ViewBag.DateSortParm }) 
    </th> 
    <th> 
     Department ID 
    </th> 
    <th> 
     Depot ID 
    </th> 
    <th> 
     Is Administrator 
    </th> 
    <th></th> 
</tr> 
+0

はい!既に削除されています! – TykiMikk