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