[asp.net mvc在编辑或详细信息视图中调用子记录

问题描述 投票:0回答:1

任何人都没有指向示例的链接,我可能会详细参考这些示例,以便从索引中在“编辑”或“详细信息”视图中调用相关子记录?

我有一个Forms的索引视图,当我单击详细信息或进行编辑时,我希望通过部分视图可以看到WorkflowEvents_View Model中的子记录。

模型

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

Controller

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

        }

没有人链接到我可能详细引用的示例的链接,这些示例用于在索引的Edit或Details视图中调用相关的子记录吗?我有一个窗体的索引视图,当我单击详细信息时...

asp.net-mvc
1个回答
0
投票

您可以使用jquery onclick事件通过('#divName')。load()方法加载部分视图。

© www.soinside.com 2019 - 2024. All rights reserved.