CONTROLLER CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace MvcTeach.Controllers
{
public class FriendController : Controller
{
dbMbkTestEntities db = new dbMbkTestEntities();
// GET: Friend
public ActionResult Index()
{
var FrndList = (from a in db.tblFriends select a).ToList();
return View(FrndList);
}
}
}
INDEX.CSHTML page code
@model IEnumerable<MvcTeach.tblFriend>
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<table class="table">
<tr>
@*<th>
@Html.DisplayNameFor(model => model.FriendID)
</th>*@
<th>
@Html.DisplayNameFor(model => model.FriendName)
</th>
<th>
@Html.DisplayNameFor(model => model.City)
</th>
<th>
@Html.DisplayNameFor(model => model.Mobile)
</th>
<th></th>
</tr>
@foreach (var item in Model) {
<tr>
@*<td>
@Html.DisplayFor(modelItem => item.FriendID)
</td>*@
<td>
@Html.DisplayFor(modelItem => item.FriendName)
</td>
<td>
@Html.DisplayFor(modelItem => item.City)
</td>
<td>
@Html.DisplayFor(modelItem => item.Mobile)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id=item.FriendID }) |
@Html.ActionLink("Details", "Details", new { id=item.FriendID }) |
@Html.ActionLink("Delete", "Delete", new { id=item.FriendID })
</td>
</tr>
}
</table>
No comments:
Post a Comment
Please, Write your valuable comments..