MVC循环产生数据


@using Webdiyer.WebControls.Mvc;  @model PagedList<MyLibrary.WEB_KEHU>  @{      int count = Model.Count();      int i = 1;  }    @{      Layout = null;  }  <!DOCTYPE html>  <html>      <head>        <meta charset="utf-8">      <meta name="viewport" content="width=device-width initial-scale=1.0">          <title>客户管理</title>        <link rel="shortcut icon" href="favicon.ico">      <link href="~/Contents/css/bootstrap.min14ed.css" rel="stylesheet" />      <link href="~/Contents/css/font-awesome.min93e3.css" rel="stylesheet" />      <link href="~/Contents/css/plugins/sweetalert/sweetalert.css" rel="stylesheet" />      <link href="~/Contents/css/animate.min.css" rel="stylesheet" />      <link href="~/Contents/css/style.min862f.css" rel="stylesheet" />      <link href="~/Contents/css/Site.css" rel="stylesheet" />      </head>    <body class="gray-bg">          <div class="wrapper wrapper-content  animated fadeInRight">          <div class="row">              <div class="col-sm-12">                  <div class="ibox ">                      <div class="ibox-title">                          <h5>客户增减员</h5>                      </div>                      <div class="ibox-content">                          <div class="bars pull-left" style="padding-bottom:10px;">                              <div class="btn-group hidden-xs" id="exampleToolbar" role="group">                                  <button type="button" class="btn btn-outline btn-default" title="添加一条新记录" onclick="check()">                                      <i class="glyphicon glyphicon-plus" aria-hidden="true"></i>                                  </button>                                  <button type="button" class="btn btn-outline btn-default" title="编辑">                                      <i class="glyphicon glyphicon-pencil" aria-hidden="true"></i>                                  </button>                                  <button type="button" class="btn btn-outline btn-default" title="删除" onclick="del();">                                      <i class="glyphicon glyphicon-trash" aria-hidden="true"></i>                                  </button>                              </div>                          </div>                          <div class="columns columns-right btn-group pull-right" style="padding-bottom:10px;">                              <button class="btn btn-default btn-outline" type="button" name="toggle" title="查询">                                  <i class="glyphicon glyphicon-search"></i>                              </button>                              <button class="btn btn-default btn-outline" type="button" name="refresh" title="刷新">                                  <i class="glyphicon glyphicon-repeat"></i>                              </button>                          </div>                          <div class="pull-right search" style="padding-bottom:10px;padding-right:6px;">                              <input class="form-control input-outline" placeholder="搜索" type="text">                          </div>                          <div id="articles">                              <table class="table table-bordered" id="lab">                                  <thead>                                      <tr>                                          <th>序号</th>                                          <th>职工名</th>                                          <th>身份证号码</th>                                          <th>大公司名称</th>                                          <th>小公司名称</th>                                          <th>户口身份</th>                                          <th>社保基数</th>                                          <th>公积金基数</th>                                          <th>公积金单位比例</th>                                          <th>公积金个人比例</th>                                          <th>公积金单位缴纳额</th>                                          <th>公积金个人缴纳额</th>                                          <th>社保开始时间</th>                                          <th>公积金开始时间</th>                                          <th>合同开始时间</th>                                          <th>合同结束时间</th>                                          <th>委托地</th>                                          <th>标识</th>                                      </tr>                                  </thead>                                  <tbody>                                      @{                                          foreach (var item in Model)                                          {                                              <tr id="@Html.DisplayFor(modelItem => item.K_ID)" onclick="show(this.id);">                                                  @{                                                                                                                if (i <= count)                                                          {                                                              <td>@i</td>                                                              i++;                                                          }                                                          <td>@Html.DisplayFor(modelItem => item.K_NAME)</td>                                                          <td>@Html.DisplayFor(modelItem => item.K_SFZID)</td>                                                          <td>@Html.DisplayFor(modelItem => item.K_DGS)</td>                                                          <td>@Html.DisplayFor(modelItem => item.K_XGS)</td>                                                          <td>@Html.DisplayFor(modelItem => item.K_YGSF)</td>                                                          <td>@Html.DisplayFor(modelItem => item.K_SBJS)</td>                                                          <td>@Html.DisplayFor(modelItem => item.K_GJJJS)</td>                                                          <td>@Html.DisplayFor(modelItem => item.K_GJJDWBL)</td>                                                          <td>@Html.DisplayFor(modelItem => item.K_GJJGRBL)</td>                                                          <td>@Html.DisplayFor(modelItem => item.K_GJJDWJNE)</td>                                                          <td>@Html.DisplayFor(modelItem => item.K_GJJGRJNE)</td>                                                          <td>@Html.DisplayFor(modelItem => item.K_SBKSSJ)</td>                                                          <td>@Html.DisplayFor(modelItem => item.K_GJJKSSJ)</td>                                                          <td>@Html.DisplayFor(modelItem => item.K_HTKSSJ)</td>                                                          <td>@Html.DisplayFor(modelItem => item.K_HTJSSJ)</td>                                                          <td>@Html.DisplayFor(modelItem => item.K_WTD)</td>                                                          <td>@Html.DisplayFor(modelItem => item.K_BS)</td>                                                      }                                              </tr>                                                      }                                      }                                    </tbody>                              </table>                          </div>                                  <div class="text-center">                                  @Ajax.Pager(Model new PagerOptions                             {                                 PageIndexParameterName = "id"                                 ContainerTagName = "ul"                                 CssClass = "pagination"                                 CurrentPagerItemTemplate = "<li class=\"active\"><a href=\"#\">{0}</a></li>"                                 DisabledPagerItemTemplate = "<li class=\"disabled\"><a>{0}</a></li>"                                 PagerItemTemplate = "<li>{0}</li>"                             }).AjaxOptions(a => a.SetUpdateTargetId("articles"))                              </div>                      </div>                  </div>              </div>                      <script src="~/Contents/js/jquery.min.js"></script>              <script src="~/Contents/js/bootstrap.min.js"></script>              <script src="~/Contents/js/content.min.js"></script>              <script src="~/Contents/js/ajax_gl.js" type="text/javascript"></script>              <script src="~/Contents/js/plugins/sweetalert/sweetalert.min.js"></script>    </body>      <!-- Mirrored from www.zi-han.net/theme/hplus/table_bootstrap.html by HTTrack Website Copier/3.x [XR&CO'2014] Wed 20 Jan 2016 14:20:06 GMT -->  </html>      using System;  using System.Collections.Generic;  using System.Linq;  using System.Web;  using System.Web.Mvc;  using MyLibrary;  using Webdiyer.WebControls.Mvc;    namespace web.Controllers  {      public class HomeController : Controller      {          private Entities et = new Entities();          // GET: Home            public ActionResult Index()          {               return View();          }          public void delzg()          {              decimal id = decimal .Parse(Request.Params["id"]);                var shanchu = et.WEB_KEHU.FirstOrDefault(k=>k.K_ID==id);              et.WEB_KEHU.Remove(shanchu);              et.SaveChanges();              Response.Write("1");          }          public ActionResult AjaxPaging(int id = 1)          {              var model= et.WEB_KEHU.OrderByDescending(a=>a.K_ID).ToPagedList(id 5);                //Session["page"] = id;              //int count = model.Count();              string sj = DateTime.Now.ToString("yyyyMMddhhmmss");              return View(model);          }          public ActionResult search()          {              return View();          }      }  }

分享这篇文章:
收藏+0