none
View is not getting refreshed in Asp.net mvc core 1.1 RRS feed

  • Question

  • I am developing an MVC web application using Asp.net core 1.1 . In view i am creating grid by looping the div's.

    @foreach (var eachItem in Model.PageProjects)
                    {
     <div class="media-body no-right">
                                    <div class="media-left">
                                        #@eachItem.ProjectNumber
                                        <h4 class="media-heading"><a href="">@eachItem.ProjectName</a></h4>
                                    </div>
                                    <div class="media-left">
                                        <h4 class="media-heading"><span class="label label-default">Stage @eachItem.Stage</span></h4>
                                    
                                    </div>
                                    <div class="media-left">
                                                                           
                                            <h4 class="media-heading">@eachItem.PmUsername</h4>
                                       
                                        <span class="text-uppercase">project manager</span>
                                    </div>
                                  
                                    <div class="media-left">
                                        <h4 class="media-heading">@eachItem.LastUpdatedOn</h4>
                                        <span class="text-uppercase">last updated</span>
                                    </div>
                                </div>
           }
    Based on the dropdown value, i want to sort the grid
      @Html.DropDownList("StageDropDown", new List<SelectListItem>
                                            {
                                                new SelectListItem { Text = "None", Value = "ProjectNumber"},
                                                new SelectListItem { Text = "Project Manager", Value = "ProjectManager" }, 
                                                new SelectListItem { Text = "Last Updated", Value = "LastUpdatedOn" , Selected = true }
                                            }, "Select Stage", new { @class = "form-control" })

    I am firing the jquery post event to call the action method

     $("#StageDropDown").on("change", function () {
        
    $.post("/Projects/Index", { sortOrder: $('#StageDropDown :selected').val(), CurrentSort: $('#currentStageSortOrder').val() });

        });

    The above  event calls action method , I am sorting the list data & it is assigned to the div by using Model, but the view is not getting refreshed, it is showing old values

    I have used DistributedMemoryCache & Session, commented both of this & tried again but still the view is not getting refreshed, it is showing old values.

    The values is getting sorted in the list but sorted values is not getting reflected when the view is rendered. 

    Could you please provide the suggestion ?

    Thanks in advance

    • Moved by CoolDadTx Wednesday, January 3, 2018 2:40 PM ASP.NET related
    Wednesday, January 3, 2018 7:15 AM

All replies