具有复选框控件的MVC网格

时间:2014-04-08 06:41:48

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

我必须在MVC4 + Razor中实现一个好看的网格。现在我已经完成了使用Table tr和td因为我是MVC的新手所以有人可以建议我如何将我的代码更改为New Good UI Grid因为我想在每一行删除该特定记录的一个复选框可以帮助我实现这一点我附加我的代码。注意我从ADO.NET DB获取值所以请给我发送网格代码以及复选框在每个记录中以及如何在该复选框上触发删除

MODEL

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>

1 个答案:

答案 0 :(得分:0)

你可以使用@ Html.CheckboxFor(x =&gt; x.item.EmpName)