简体   繁体   English

在网格等视图上显示数据; 在MVC中

[英]displaying data on view like Grid; in MVC

i am newbie to MVC 3 and Linq to Sql, trying to display data on VIEW which i am getting from database. 我是MVC 3的新手,还是SQL的Linq,试图在从数据库中获取的VIEW上显示数据。 I did it via tables but don't like it, i need something like Gridview (add, delete, update) etc but couldn't find proper way. 我是通过表格完成的,但是不喜欢它,我需要诸如Gridview(添加,删除,更新)之类的东西,但是找不到正确的方法。 i tried Grid.MVC but couldn't find a way to connect it to my code. 我尝试了Grid.MVC,但找不到将其连接到我的代码的方法。 Any way for grid display with respect to my code ? 关于我的代码的网格显示有什么办法吗?

Controller: 控制器:

using EmployeeAttendance_app.Models;
namespace EmployeeAttendance_app.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            ViewBag.Message = "Precise Technology Consultants";
            var DataContext = new EmployeeAtdDataContext();
            var EmployeeAtd = DataContext.GetAttendance_Sp();
            return View(EmployeeAtd);
        }

View: 视图:

<table>

 <tr>

      <th>
       Employer ID
      </th>
      <th>
       Employer Name
      </th>
      <th>
       Rec Date
      </th>
      <th>
       Rec Time
      </th>
      <th>
       Department Name
      </th>
 </tr>

 @foreach (GetAttendance_SpResult emp in (IEnumerable<GetAttendance_SpResult>)ViewData.Model) 
 {


     <tr>

      <td>@emp.EmplID</td>
      <td>@emp.EmplName</td>
      <td>@emp.RecDate</td>
      <td>@emp.RecTime</td>
      <td>@emp.DeptName</td>

     </tr>

 }
</table>

Not tried Grid yet (have been using tables and for loops);but, a quick search turned up Grid.MVC.ajax Grid.Mvc.Ajax extension grid initialization 尚未尝试使用Grid(一直在使用表和for循环);但是,快速搜索打开了Grid.MVC.ajax Grid.Mvc.Ajax扩展网格初始化

If (ok when) I try this on Monday, I'll follow the 8 steps provided in the Grid.MVC.Ajax readmelink referenced above... and update this comment... 如果(星期一什么时候)尝试,我将遵循上面引用的Grid.MVC.Ajax readmelink中提供的8个步骤...并更新此评论...

Two methods I have used are detailed below. 下面详细介绍了我使用的两种方法。

The first was a hybrid of jquery, datatables and mvc. 首先是jquery,datatables和mvc的混合体。

There is a good article on this at code project: 代码项目上有一篇很好的文章:

http://www.codeproject.com/Articles/165410/ASP-NET-MVC-Editable-DataTable-jQuery-DataTables-a http://www.codeproject.com/Articles/165410/ASP-NET-MVC-Editable-DataTable-jQuery-DataTables-a

The second was with kendo ui mvc helper grid: 第二个是用kendo ui mvc helper网格:

http://docs.kendoui.com/getting-started/using-kendo-with/aspnet-mvc/helpers/grid/overview http://docs.kendoui.c​​om/getting-started/using-kendo-with/aspnet-mvc/helpers/grid/overview

The second being a pay for component. 第二个是薪水部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM