【问题标题】:MVC Grid with Checkbox Control带有复选框控件的 MVC 网格
【发布时间】:2014-04-08 17:43:23
【问题描述】:

我必须在 MVC4+Razor 中实现一个好看的网格。直到现在我已经使用 Table tr 和 td 完成了因为我是 MVC 的新手所以有人可以建议我如何将我的代码也更改为 New Good UI Grid因为我希望每一行都有一个复选框来删除该特定记录 有人可以帮助我实现这一点吗?在每条记录中以及如何在该复选框上触发 Delete

型号

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

namespace Employee_Mgmt_System.Models
{
    public class AdminHomeScreen
    {
        public string EmpID { get; set; }
        public string EmpName { get; set; }
        public string CountryName { get; set; }
        public string StateName { get; set; }
        public string CityName { get; set; }
        public string EmailAddress { get; set; }


    }
}

控制器

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Employee_Mgmt_System.Models;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

namespace Employee_Mgmt_System.Controllers
{
    public class AdminHomeScreenController : Controller
    {
        //
        // GET: /AdminHomeScreen/

        public ActionResult AdminHomeScreen()
        {

                return View();


        }

    }
}

查看

@model IEnumerable<Employee_Mgmt_System.Models.AdminHomeScreen>
@{
    ViewBag.Title = "Admin Home Screen";
}

<h2> Admin Home Screen</h2>
<div id="AdminScreen" style="background-color:azure">
<table border="1" style="border-color:black">
    <tr>
        <td style="font:25px">EMPID</td>
        <td style="font:25px">Employee Name</td>
        <td style="font:25px">Country</td>
        <td style="font:25px">State</td>
        <td style="font:25px">City</td>
        <td style="font:25px">EmailAddress</td>
    </tr>
         @foreach(var item in Model)
        {
            <tr>
                <td style="font:25px">@Html.DisplayFor(model=>item.EmpID)</td>
                <td style="font:25px">@Html.DisplayFor(model=>item.EmpName)</td>
                <td style="font:25px">@Html.DisplayFor(model=>item.CountryName)</td>
                <td style="font:25px">@Html.DisplayFor(model=>item.StateName)</td>
                <td style="font:25px">@Html.DisplayFor(model=>item.CityName)</td>
                <td style="font:25px">@Html.DisplayFor(model=>item.EmailAddress)</td>
            </tr>
        }

</table>
</div>

【问题讨论】:

    标签: jquery asp.net-mvc asp.net-mvc-4 razor


    【解决方案1】:

    你可以使用@Html.CheckboxFor(x=>x.item.EmpName)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-10-21
      • 1970-01-01
      • 2012-10-31
      • 1970-01-01
      • 2013-04-17
      • 2011-01-26
      • 1970-01-01
      • 2011-05-14
      相关资源
      最近更新 更多