Note that there are some explanatory texts on larger screens.

plurals
  1. POMain View eliminates a filter after I create an element from a partial view
    primarykey
    data
    text
    <p>Mi trouble is this: I have a View called "Create" it refers to the creation of promotions. Each promotion has Genres according to the user, so, when I do enter to the "create promotions" I have a list (dropdown) with the genres of the user, but if there is no an adecuate genre I must create it without leaving the current page, so I used a partial view for creating new genres and I inserted it in the main view (Create promotions) It do works, but after the genre is created, the main view shows ALL the genres and not only those who correspond to the current user.</p> <p>This is the main view: </p> <pre><code>@model Points2Pay.Models.Promocion @{ ViewBag.Title = "Create"; } &lt;h2&gt;Create&lt;/h2&gt; &lt;script type="text/javascript"&gt; $(document).ready(function () { $(".slidingDiv").hide(); $(".show_hide").show(); $('.show_hide').click(function () { $(".slidingDiv").slideToggle(); }); }); </code></pre> <p></p> <pre><code>@using (Html.BeginForm()) { &lt;a href="#" class="show_hide"&gt;Show/hide&lt;/a&gt; &lt;div class="slidingDiv" id="partialView"&gt; @{Html.RenderAction("Create2", "Genre");} &lt;/div&gt; } @using (Html.BeginForm("Create","StoreManager")) { @Html.ValidationSummary(true) &lt;fieldset&gt; &lt;legend&gt;Promocion&lt;/legend&gt; &lt;div class="editor-label"&gt; @Html.LabelFor(model =&gt; model.GenreId, "Genre") &lt;/div&gt; &lt;div class="editor-field" id="DROPDOWN"&gt; @Html.DropDownList("GenreId", String.Empty) @Html.ValidationMessageFor(model =&gt; model.GenreId) &lt;/div&gt; &lt;div class="editor-label"&gt; @Html.LabelFor(model =&gt; model.Title) &lt;/div&gt; &lt;div class="editor-field"&gt; @Html.EditorFor(model =&gt; model.Title) @Html.ValidationMessageFor(model =&gt; model.Title) &lt;/div&gt; &lt;div class="editor-label"&gt; @Html.LabelFor(model =&gt; model.Price) &lt;/div&gt; &lt;div class="editor-field"&gt; @Html.EditorFor(model =&gt; model.Price) @Html.ValidationMessageFor(model =&gt; model.Price) &lt;/div&gt; &lt;div class="editor-label"&gt; @Html.LabelFor(model =&gt; model.Puntos) &lt;/div&gt; &lt;div class="editor-field"&gt; @Html.EditorFor(model =&gt; model.Puntos) @Html.ValidationMessageFor(model =&gt; model.Puntos) &lt;/div&gt; &lt;div class="editor-label"&gt; @Html.LabelFor(model =&gt; model.PromocionArtUrl) &lt;/div&gt; &lt;div class="editor-field"&gt; @Html.EditorFor(model =&gt; model.PromocionArtUrl) @Html.ValidationMessageFor(model =&gt; model.PromocionArtUrl) &lt;/div&gt; &lt;p&gt; &lt;input type="submit" value="Create" /&gt; &lt;/p&gt; &lt;/fieldset&gt; } &lt;div&gt; @Html.ActionLink("Back to List", "Index") &lt;/div&gt;` </code></pre> <p>THIS IS THE SECONDARY VIEW</p> <pre><code> @model Points2Pay.Models.Genre &lt;script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"&gt;&lt;/script&gt; @using (Html.BeginForm()) { @Html.ValidationSummary(true) &lt;legend&gt;New Genre&lt;/legend&gt; &lt;div class="editor-label"&gt; @Html.LabelFor(model =&gt; model.Name) &lt;/div&gt; &lt;div class="editor-field"&gt; @Html.EditorFor(model =&gt; model.Name) @Html.ValidationMessageFor(model =&gt; model.Name) &lt;/div&gt; &lt;div class="editor-label"&gt; @Html.LabelFor(model =&gt; model.Description) &lt;/div&gt; &lt;div class="editor-field"&gt; @Html.EditorFor(model =&gt; model.Description) @Html.ValidationMessageFor(model =&gt; model.Description) &lt;/div&gt; &lt;p&gt; &lt;input type="submit" value="Create new Genre" /&gt; &lt;/p&gt; } </code></pre> <p>AND THIS IS THE CONTROLLER</p> <pre><code>[ChildActionOnly] public ActionResult Create2() { return PartialView("Create2"); } // // POST: /Genre/Create2 [HttpPost] public ActionResult Create2(Genre genre) { var ComercioActual = (Guid)System.Web.Security.Membership.GetUser().ProviderUserKey; if (ModelState.IsValid) { genre.ComercioId = ComercioActual; db.Genres.Add(genre); db.SaveChanges(); return PartialView("Create2"); } return PartialView("Create2"); } </code></pre> <p>Hope you can help me.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload