title: ASP.NET MVC: How to put a create partial view in an index view?
body: <p>I have an index view grid that i would like to put a create partial view at the bottom of-- that way a user can create a new item on the same page as viewing all items. However, upon submitting the partial create view, nothing happens to the main index page; it doesn't update with the new item (although its there after a refresh). </p>
  
  <p>Index page:</p>
  
  <pre><code>&lt;%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage&lt;IEnumerable&lt;Paris.Domain.Models.PhoneNumberType&gt;&gt;" %&gt;
  
  &lt;asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"&gt;
      Index
  &lt;/asp:Content&gt;
  
  &lt;asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"&gt;
  
      &lt;h2&gt;Index&lt;/h2&gt;
      &lt;table&gt;
          &lt;tr&gt;
              &lt;th&gt;&lt;/th&gt;
              &lt;th&gt;
                  PhoneNumberTypeID
              &lt;/th&gt;
              &lt;th&gt;
                  Name
              &lt;/th&gt;
          &lt;/tr&gt;
  
      &lt;% foreach (var item in Model) { %&gt;
  
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;%: Html.ActionLink("Edit", "Edit", new { id=item.PhoneNumberTypeID}) %&gt; |
                  &lt;%: Html.ActionLink("Delete", "Delete", new { id=item.PhoneNumberTypeID })%&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;%: item.PhoneNumberTypeID %&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;%: item.Name %&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
  
      &lt;% } %&gt;
      &lt;/table&gt;
  
      &lt;p&gt;
          Create New
      &lt;/p&gt;
      &lt;% Html.RenderAction("Create"); %&gt;
  
  &lt;/asp:Content&gt;
  </code></pre>
  
  <p>And here is the controller:</p>
  
  <pre><code>    using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.Mvc;
  using Paris.Domain.Access;
  
  namespace Paris.Web.Areas.Domain.Controllers
  {
      public class PhoneNumberTypesController : Controller
      {
          //
          // GET: /Domain/PhoneNumberTypes/
          private IRepository&lt;Paris.Domain.Models.PhoneNumberType&gt; db;
          public PhoneNumberTypesController(IRepository&lt;Paris.Domain.Models.PhoneNumberType&gt; context)
          {
              db=context;
          }
          public ViewResult Index()
          {
  
              return View(db.Get().Select(i=&gt;i));
          }
          public ViewResult IndexCreate(Paris.Domain.Models.PhoneNumberType num)
          {
              Create(num);
              return View();
          }
          public ViewResult Edit()
          {
              return View();
          }
          [HttpPost]
          public ViewResult Edit(Paris.Domain.Models.PhoneNumberType num)
          {
              try
              {
                  if (ModelState.IsValid)
                  {
                      db.Update(num);
                      return Index();
                  }
                  else
                      return View();
              }
              catch
              {
                  return View();
              }
          }
          [HttpPost]
          public ViewResult Delete(int PhoneNumberTypeID)
          {
              db.Delete(db.Get().First(i =&gt; i.PhoneNumberTypeID == PhoneNumberTypeID));
  
              return Index();
          }
          [HttpPost]
          public ViewResult Create(Paris.Domain.Models.PhoneNumberType num)
          {
              try
              {
                  if (ModelState.IsValid)
                  {
                      db.Create(num);
                      return View();
                  }
                  else
                      return View();
              }
              catch
              {
                  return View();
              }
          }
          [HttpGet]
          public ViewResult Create()
          {
              return View();
          }
      }
  }
  </code></pre>
  
  <p>If i am doing this completely wrong, feel free to point out how my thinking is flawed. </p>
  
  <p>Thanks</p>