有人可以链接到示例,我可能会详细参考这些示例以从索引中在“编辑”或“详细信息”视图中调用相关的子记录吗?
我有一个窗体的索引视图,当我单击详细信息或进行编辑时,我希望通过局部视图可以看到WorkflowEvents_View模型中的子记录。
模型
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated from a template.
//
// Manual changes to this file may cause unexpected behavior in your application.
// Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace WebApplication5.Models
{
using System;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
public partial class PowerPlatformEntities : DbContext
{
public PowerPlatformEntities()
: base("name=PowerPlatformEntities")
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
throw new UnintentionalCodeFirstException();
}
public virtual DbSet<ListValues> ListValues { get; set; }
public virtual DbSet<Forms> Forms { get; set; }
public virtual DbSet<Forms_View> Forms_View { get; set; }
public virtual DbSet<WorkflowEvents_View> WorkflowEvents_View { get; set; }
}
}
控制器
namespace WebApplication5.Controllers
{
public class FormsController : Controller
{
private PowerPlatformEntities db = new PowerPlatformEntities();
// GET: Forms
public ActionResult Index()
{
return View(db.Forms_View.OrderByDescending(Forms => Forms.Modified).Take(100).ToList());
}
// GET: WorkflowEvents_View
public ActionResult WorkflowEvents_View(int? FormID)
{
//return View(db.WorkflowEvents_View.OrderByDescending(WorkflowEvents_View => WorkflowEvents_View.Created).Take(100).ToList());
return PartialView("WorkflowEvents_View", db.Forms.Find(FormID));
}
// GET: Forms/Details/5
public ActionResult Details(int? FormID)
{
//var viewModel = new PowerPlatformEntities();
Trace.WriteLine("GET /Forms/Details/" + FormID);
if (FormID == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Forms form = db.Forms.Find(FormID);
if (form == null)
{
return HttpNotFound();
}
return View(form);
}
答案 0 :(得分:0)
您可以使用('#divName')。load()方法使用jquery onclick事件加载部分视图。