C# 对齐MVC4 Index.cshtml中的列

C# 对齐MVC4 Index.cshtml中的列,c#,asp.net-mvc,entity-framework,C#,Asp.net Mvc,Entity Framework,这是一个带有EF6的web应用程序MVC4,具有代码优先迁移 我的列对齐有问题。我添加了箭头以显示每个标题的位置。 我需要添加什么代码才能使它们正确对齐 视图\用户\创建.cshtml @using PagedList; @using PagedList.Mvc; <link href="~/Content/PagedList.css" rel="stylesheet" type="text/css" /> @model IPagedList<RecreationalServ

这是一个带有EF6的web应用程序MVC4,具有代码优先迁移

我的列对齐有问题。我添加了箭头以显示每个标题的位置。 我需要添加什么代码才能使它们正确对齐

视图\用户\创建.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 }))
@使用页面列表;
@使用PagedList.Mvc;
@IPagedList模型
@{
ViewBag.Title=“用户”;
}
使用者

@ActionLink(“新建”、“创建”)

@使用(Html.BeginForm(“Index”,“Users”,FormMethod.Get)) { 按名称查找:@Html.TextBox(“SearchString”,ViewBag.CurrentFilter为字符串)

} 名字 @ActionLink(“姓氏”,“索引”,新的{sortOrder=ViewBag.NameSortParm}) @ActionLink(“注册日期”,“索引”,new{sortOrder=ViewBag.DateSortParm}) 部门ID 仓库ID 是管理员吗 @foreach(模型中的var项目){ @DisplayFor(modelItem=>item.FirstMidName) @DisplayFor(modelItem=>item.LastName) @DisplayFor(modelItem=>item.EnrollmentDate) @DisplayFor(modelItem=>item.Department.DepartmentName) @DisplayFor(modelItem=>item.Depot.DepotName) @DisplayFor(modelItem=>item.IsAdministrator) @ActionLink(“编辑”,“编辑”,新的{id=item.UserID})| @ActionLink(“详细信息”,“详细信息”,新的{id=item.UserID})| @ActionLink(“删除”,“删除”,新的{id=item.UserID}) } @Model.PageCount的@页(Model.PageCountUrl.Action(“Index”,new{page,sortOrder=ViewBag.CurrentSort,currentFilter=ViewBag.currentFilter}))
看起来您有一个空的

<th></th> 

<>标签在标题行的中间。您可能希望将其移动到标题行的末尾,其中包含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>

名字
@ActionLink(“姓氏”,“索引”,新的{sortOrder=ViewBag.NameSortParm})
@ActionLink(“注册日期”,“索引”,new{sortOrder=ViewBag.DateSortParm})
部门ID
仓库ID
是管理员吗

您需要使用thead和tbody标签:

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

/*您的列名*/
/* ... */
/*... */