2014-01-18 54 views
0

我是MVC 3和Linq to Sql的新手,试图在数据库中显示VIEW数据。我通过表做过,但不喜欢它,我需要像Gridview(添加,删除,更新)等,但无法找到正确的方式。我尝试过Grid.MVC,但找不到将其连接到我的代码的方法。任何方式网格显示相对于我的代码?像网格一样显示数据MVC

控制器:

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); 
     } 

查看:

<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> 

回答

0

没试过网尚(已使用表和循环);但是,快速搜索止跌回升Grid.MVC.ajax Grid.Mvc.Ajax extension grid initialization

如果(OK时),我尝试这个星期一,我会按照在Grid.MVC.Ajax提供readmelink上面提到的8步......并更新这条评论...