I need to perform Create, List, Update in Single screen insted of separete views in Mvc.
Can anybody suggest how to do this. I tried with partial view but could not accomplish the task.
Pls help
this is my view
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<IEnumerable<MvcMaster.Models.Mast_Lab>>" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Index</title>
</head>
<body>
<table>
<tr>
<%Html.RenderPartial("Create"); %>
</tr>
<tr>
<th></th>
<th>
iMast_Lab_id
</th>
<th>
cLab_Name
</th>
<th>
dCreate_dt
</th>
<th>
bActive
</th>
</tr>
<% foreach (var item in Model) { %>
<tr>
<td>
<%: Html.ActionLink("Edit", "Edit", new { id=item.iMast_Lab_id }) %> |
<%: Html.ActionLink("Details", "Details", new { id=item.iMast_Lab_id })%> |
<%: Html.ActionLink("Delete", "Delete", new { id=item.iMast_Lab_id })%>
</td>
<td>
<%: item.iMast_Lab_id %>
</td>
<td>
<%: item.cLab_Name %>
</td>
<td>
<%: String.Format("{0:g}", item.dCreate_dt) %>
</td>
<td>
<%: item.bActive %>
</td>
</tr>
<% } %>
</table>
</body>
</html>
and this is controller class
private LabDataContext db = new LabDataContext();
public ActionResult Index()
{
var lb = (from l in db.Mast_Labs select l);//.FirstOrDefault();
return View(lb);
//Models.Mast_Lab DocMstrEdit = (from v in db.Mast_Labs
// select v).FirstOrDefault();
//return View(DocMstrEdit);
}
public ActionResult Create()
{
return View();
}
public ActionResult CreateNew(string LabName)
{
var lb = new Mast_Lab();
lb.cLab_Name=LabName;
lb.dCreate_dt=DateTime.Now;
lb.bActive=1;
db.Mast_Labs.InsertOnSubmit(lb);
db.SubmitChanges();
return View();
}