locked
razorcrud - sort works on its own and search works on its own but but when do search and then try sort displays no results  RRS feed

  • Question

  • User915516305 posted

    Hi,

    using the tutorial https://docs.microsoft.com/en-us/aspnet/core/data/ef-rp/sort-filter-page?view=aspnetcore-2.2

    sort works on its own and search works on its own but but when do search and then try sort displays no results 

    any thoughts why?

    have c# code below 

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Threading.Tasks;
    using Microsoft.AspNetCore.Mvc;
    using Microsoft.AspNetCore.Mvc.RazorPages;
    using Microsoft.EntityFrameworkCore;
    using RazorCRUD.Models;
    using RazorCRUD.Paging;
    using Microsoft.AspNetCore.Mvc.Rendering;
    
    namespace RazorCRUD.Pages.MULTIPLES
    {
        public class IndexModel : PageModel
        {
            private readonly RazorCRUD.Models.RazorCRUDContext _context;
    
            public IndexModel(RazorCRUD.Models.RazorCRUDContext context)
            {
                _context = context;
            }
    
             public string NameSort { get; set; }
        public string CodeSort { get; set; }
        public string CurrentFilter { get; set; }
        public string CurrentSort { get; set; }
    
    
            public PaginatedList<MULTIPLE> MULTIPLE { get;set; }
    
                        [BindProperty(SupportsGet = true)]
                    public string SearchString { get; set; }
                    // Requires using Microsoft.AspNetCore.Mvc.Rendering;
                    public SelectList MultipleNames { get; set; }
                    [BindProperty(SupportsGet = true)]
                    public string MULT_NAME { get; set; }
    
            public async Task OnGetAsync(string sortOrder,
                string currentFilter, string searchString, int? pageIndex)
            {
                  
                //MULTIPLES = await _context.MULTIPLE
                
                CurrentSort = sortOrder;
    
                //MULTIPLE = await _context.Movie.ToListAsync();
    
    
                NameSort = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
                CodeSort = sortOrder == "Code" ? "code_desc" : "Code";
                if (searchString != null)
                    {
                        pageIndex = 1;
                    }
                    else
                    {
                        searchString = currentFilter;
                    }
    
                CurrentFilter = searchString;
    
                   // IQueryable<MULTIPLE> multipleIQ = from s in _context.MULTIPLE.Include("CHANNELS")
                    IQueryable<MULTIPLE> multipleIQ = from s in _context.MULTIPLE.Include("CHANNELS")
                                                        select s;
    
                                                       if (!String.IsNullOrEmpty(searchString))
                                                        {
                                                            multipleIQ = multipleIQ.Where(s => s.MULT_NAME.Contains(SearchString));
                                                        }
    
    
                        switch (sortOrder)
                        {
                            case "name_desc":
                                multipleIQ = multipleIQ.OrderByDescending(s => s.MULT_NAME);
                                break;
                            case "Code":
                                multipleIQ = multipleIQ.OrderBy(s => s.MULT_MULTIPLE_CODE);
                                break;
                            case "code_desc":
                                multipleIQ = multipleIQ.OrderByDescending(s => s.MULT_MULTIPLE_CODE);
                                break;
                            default:
                                multipleIQ = multipleIQ.OrderBy(s => s.MULT_NAME);
                                break;
                        }
    
                         int pageSize = 50;
                            MULTIPLE = await PaginatedList<MULTIPLE>.CreateAsync(
                            multipleIQ.AsNoTracking(), pageIndex ?? 1, pageSize);
    
    
    //MULTIPLE = await _context.MULTIPLE
                    //.Include(c => c.CHANNELS)
                   // .AsNoTracking()
                   // .ToListAsync();
                             //.Include(c => c.CHANNELS);
    
                             //ChannelTypes = new SelectList(_context.Channel_Types, "Channel_Type_Code", "Channel_Type_Name");//added 21/05/19
    
                      //  MULTIPLE = await multipleIQ.AsNoTracking().ToListAsync(); commented out 10/05/2019
    
    
                         //   var mlist = from m in _context.MULTIPLE
                         //   select m;
                         //   if (!string.IsNullOrEmpty(SearchString))
                         //   {
                         //       mlist = mlist.Where(s => s.MULT_NAME.Contains(SearchString));
                         //   }
    
                      // MULTIPLE = await mlist.ToListAsync();
                //MULTIPLE = await _context.mlist.ToListAsync();
            }
    
    
        }
    }
    

    and chttml 

    @page
    @model RazorCRUD.Pages.MULTIPLES.IndexModel

    @{
    ViewData["Title"] = "Index";
    }

    <h2>Maintain Multiple Index</h2>

    <p>
    <a asp-page="Create">Create New</a>
    </p>

    <!--form>
    <p>
    Multiple Name: <input type="text" asp-for="SearchString" />
    <input type="submit" value="Filter" />
    </p>
    </form-->

    <form asp-page="./Index" method="get">
    <div class="form-actions no-color">
    <p>
    Find by name:
    <input type="text" name="SearchString" value="@Model.CurrentFilter" />
    <input type="submit" value="Search" class="btn btn-default" /> |
    <a asp-page="./Index">Back to full List</a>
    </p>
    </div>
    </form>

    <table class="table table-striped">
    <thead>
    <tr>
    <th>
    <a asp-page="./Index" asp-route-sortOrder="@Model.CodeSort"
    asp-route-currentFilter="@Model.CurrentFilter">
    @Html.DisplayNameFor(model => model.MULTIPLE[0].MULT_MULTIPLE_CODE)
    </a>
    </th>
    <th>
    <a asp-page="./Index" asp-route-sortOrder="@Model.NameSort"
    asp-route-currentFilter="@Model.CurrentFilter">
    @Html.DisplayNameFor(model => model.MULTIPLE[0].MULT_NAME)
    </a>
    </th>
    @* <th>
    @Html.DisplayNameFor(model => model.MULTIPLE[0].MULT_SELECTED_MULTIPLE)
    </th>*@
    <th>
    @Html.DisplayNameFor(model => model.MULTIPLE[0].MULT_ANMW_MULTIPLE_CODE)
    </th>
    <th>
    @Html.DisplayNameFor(model => model.MULTIPLE[0].MULT_LINK_MULTIPLE_CODE)
    </th>
    <th>
    @Html.DisplayNameFor(model => model.MULTIPLE[0].MULT_JMW_MULTIPLE_TYPE_CODE)
    </th>
    @* <th>
    @Html.DisplayNameFor(model => model.MULTIPLE[0].MULT_AUTH_REQUIRED)
    </th>
    <th>
    @Html.DisplayNameFor(model => model.MULTIPLE[0].MULT_PROM_AUTH_REQUIRED)
    </th>*@
    <th></th>
    </tr>
    </thead>
    <tbody>
    @foreach (var item in Model.MULTIPLE) {
    <tr>
    <td>
    @Html.DisplayFor(modelItem => item.MULT_MULTIPLE_CODE)
    </td>
    <td>
    @Html.DisplayFor(modelItem => item.MULT_NAME)
    </td>
    @* <td>
    @Html.DisplayFor(modelItem => item.MULT_SELECTED_MULTIPLE)
    </td> *@
    <td>
    @Html.DisplayFor(modelItem => item.MULT_ANMW_MULTIPLE_CODE)
    </td>
    <td>
    @Html.DisplayFor(modelItem => item.MULT_LINK_MULTIPLE_CODE)
    </td>
    <td>
    @Html.DisplayFor(modelItem => item.CHANNELS.CHA_NAME)
    </td>
    @*<td>
    @Html.DisplayFor(modelItem => item.MULT_AUTH_REQUIRED)
    </td>
    <td>
    @Html.DisplayFor(modelItem => item.MULT_PROM_AUTH_REQUIRED)
    </td> *@
    <td>
    <a asp-page="./Edit" asp-route-id="@item.MULT_MULTIPLE_CODE">Edit</a> |
    <a asp-page="./Details" asp-route-id="@item.MULT_MULTIPLE_CODE">Details</a> |
    <a asp-page="./Delete" asp-route-id="@item.MULT_MULTIPLE_CODE">Delete</a>
    </td>
    </tr>
    }
    </tbody>
    </table>
    @{
    var prevDisabled = !Model.MULTIPLE.HasPreviousPage ? "disabled" : "";
    var nextDisabled = !Model.MULTIPLE.HasNextPage ? "disabled" : "";
    }
    <a asp-page="./Index"
    asp-route-sortOrder="@Model.CurrentSort"
    asp-route-pageIndex="@(Model.MULTIPLE.PageIndex - 1)"
    asp-route-currentFilter="@Model.CurrentFilter"
    class="btn btn-default @prevDisabled">
    Previous
    </a>
    <a asp-page="./Index"
    asp-route-sortOrder="@Model.CurrentSort"
    asp-route-pageIndex="@(Model.MULTIPLE.PageIndex + 1)"
    asp-route-currentFilter="@Model.CurrentFilter"
    class="btn btn-default @nextDisabled">
    Next
    </a>
    Monday, September 9, 2019 3:58 PM

Answers

  • User711641945 posted

    Hi poR,

    I have uploaded my project on github here.

    Best Regards,

    Rena

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 12, 2019 9:31 AM

All replies

  • User711641945 posted

    Hi poR,

    From my code,I suggest you need to change the searchString which marked in green.Here is a simple demo like below:

    1.Model:

    public class MULTIPLE
    {
        [Key]
        public int Id { get; set; }
        public string MULT_MULTIPLE_CODE { get; set; }
        public string MULT_NAME { get; set; }
        public string MULT_SELECTED_MULTIPLE { get; set; }
        public string MULT_ANMW_MULTIPLE_CODE { get; set; }
        public string MULT_LINK_MULTIPLE_CODE { get; set; }
        public string CHA_NAME { get; set; }
        public string MULT_AUTH_REQUIRED { get; set; }
        public string MULT_PROM_AUTH_REQUIRED { get; set; }
    }

    2.Index.cshtml:

    @page
    @modelIndexModel
    <p>
        <a asp-page="Create">Create New</a>
    </p>
    <form asp-page="./Index" method="get">
        <div class="form-actions no-color">
            <p>
                Find by name: <input type="text" name="SearchString" value="@Model.CurrentFilter" />
                <input type="submit" value="Search" class="btn btn-default" /> |           
                <a asp-page="./Index">Back to full List</a>
            </p>
        </div>
    </form>
    <table class="table">
        <thead>
            <tr>
                <th>
                    <a asp-page="./Index" asp-route-sortOrder="@Model.CodeSort"
               asp-route-currentFilter="@Model.CurrentFilter">
                @Html.DisplayNameFor(model => model.MULTIPLE[0].MULT_MULTIPLE_CODE)
            </a>             
                </th>
                <th>
                    <a asp-page="./Index" asp-route-sortOrder="@Model.NameSort"
               asp-route-currentFilter="@Model.CurrentFilter">
                @Html.DisplayNameFor(model => model.MULTIPLE[0].MULT_NAME)
            </a>
                </th>
                //more code...
                <th></th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in Model.MULTIPLE)
            {
                <tr>
                    <td>
                        @Html.DisplayFor(modelItem => item.MULT_MULTIPLE_CODE)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.MULT_NAME)
                    </td>
                    //more code...
                    <td>
                        <a asp-page="./Edit" asp-route-id="@item.MULT_MULTIPLE_CODE">Edit</a> |
                        <a asp-page="./Details" asp-route-id="@item.MULT_MULTIPLE_CODE">Details</a> |
                        <a asp-page="./Delete" asp-route-id="@item.MULT_MULTIPLE_CODE">Delete</a>
                    </td>
                </tr>
            }
        </tbody>
    </table>
    @{
        var prevDisabled = !Model.MULTIPLE.HasPreviousPage ? "disabled" : "";
        var nextDisabled = !Model.MULTIPLE.HasNextPage ? "disabled" : "";
    }
    <a asp-page="./Index"
       asp-route-sortOrder="@Model.CurrentSort"
       asp-route-pageIndex="@(Model.MULTIPLE.PageIndex - 1)"
       asp-route-currentFilter="@Model.CurrentFilter"
       class="btn btn-default @prevDisabled">
        Previous
    </a>
    <a asp-page="./Index"
       asp-route-sortOrder="@Model.CurrentSort"
       asp-route-pageIndex="@(Model.MULTIPLE.PageIndex + 1)"
       asp-route-currentFilter="@Model.CurrentFilter"
       class="btn btn-default @nextDisabled">
        Next
    </a>

    3.Index.cshtml.cs:

    public class IndexModel : PageModel
        {
            private readonly RazorPageProj2Context _context;
            public IndexModel(RazorPageProj2Context context)
            {
                _context = context;
            }
            public string NameSort { get; set; }
            public string CodeSort { get; set; }
            public string CurrentFilter { get; set; }
            public string CurrentSort { get; set; }
            public PaginatedList<MULTIPLE> MULTIPLE { get; set; }
            [BindProperty(SupportsGet = true)]
            public string SearchString { get; set; }
            // Requires using Microsoft.AspNetCore.Mvc.Rendering;
            public SelectList MultipleNames { get; set; }
            [BindProperty(SupportsGet = true)]
            public string MULT_NAME { get; set; }
    
            public async Task OnGetAsync(string sortOrder,
                string currentFilter, string searchString, int? pageIndex)
            {
                CurrentSort = sortOrder;
                NameSort = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
                CodeSort = sortOrder == "Code" ? "code_desc" : "Code";
                if (searchString != null)
                {
                    pageIndex = 1;
                }
                else
                {
                    searchString = currentFilter;
                }
                CurrentFilter = searchString;
                // IQueryable<MULTIPLE> multipleIQ = from s in _context.MULTIPLE.Include("CHANNELS")
                IQueryable<MULTIPLE> multipleIQ = from s in _context.MULTIPLE
                                                  select s;
                if (!String.IsNullOrEmpty(searchString))
                {
                    multipleIQ = multipleIQ.Where(s => s.MULT_NAME.Contains(searchString));                
                }     
                    switch (sortOrder)
                    {
                        case "name_desc":
                            multipleIQ = multipleIQ.OrderByDescending(s => s.MULT_NAME);
                            break;
                        case "Code":
                            multipleIQ = multipleIQ.OrderBy(s => s.MULT_MULTIPLE_CODE);
                            break;
                        case "code_desc":
                            multipleIQ = multipleIQ.OrderByDescending(s => s.MULT_MULTIPLE_CODE);
                            break;
                        default:
                            multipleIQ = multipleIQ.OrderBy(s => s.MULT_NAME);
                            break;              
                }            
                int pageSize = 50;
                MULTIPLE = await PaginatedList<MULTIPLE>.CreateAsync(
                multipleIQ.AsNoTracking(), pageIndex ?? 1, pageSize);
            }
        }

    Best Regards,

    Rena

    Tuesday, September 10, 2019 4:34 AM
  • User915516305 posted

    Hi,

    Thanks for suggestion.

    Tried changing from SearchString to searchString for the highlighted green part you advised but still doesn't sort after entering search string and displays no rows.

    Any other thoughts?

    Thanks

    searchString
    Tuesday, September 10, 2019 8:55 AM
  • User711641945 posted

    Hi poR,

    I suggest that you could share your model and cshtml file with right format.Then I could test your code and resolve your issue.

    Or you could refer to my whole project here.

    Best Regards,

    Rena

    Tuesday, September 10, 2019 9:18 AM
  • User915516305 posted

    Hi Rena,

    Please see below.  Hope right format

    Thanks for your help.

    Models

    CHANNELS.cs

    using System;
    using System.Collections.Generic;
    using System.ComponentModel.DataAnnotations;
    using System.ComponentModel.DataAnnotations.Schema;
    using Microsoft.EntityFrameworkCore;
    
    namespace RazorCRUD.Models
    {
    public class CHANNELS
        {
            [Key]
            public string CHA_NUM { get; set; }
            public string CHA_NAME { get; set; }
    
    
          //  public DbSet<Product_Type> Product_Types {get;set;}
        }
    
    
    
    }

    MULTIPLES.cs

    using System;
    using System.Collections.Generic;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Threading.Tasks;
    using Microsoft.EntityFrameworkCore;
    using System.ComponentModel.DataAnnotations.Schema;
    
    namespace RazorCRUD.Models
    {
        //public class Multiple
        public class MULTIPLE
      
        {
            private const string V = "Channel";
    
            [Key] 
             [Display(Name="Code")]
            public int MULT_MULTIPLE_CODE { get; set; } = 5005;
    
            [StringLength(60, MinimumLength = 6)]
            
            [Display(Name="Name")]
            [Required] public string MULT_NAME { get; set; }
    
            public string MULT_SELECTED_MULTIPLE { get; set; }
    
            [Required]
            [MinLength(2)]
            [MaxLength(3)]
            [RegularExpression("^[a-zA-Z0-9]*$", ErrorMessage = "Only Alphabetic and Numberic characters allowed.")]
    
            [Display(Name="ANMW Multiple Code")]
            public string MULT_ANMW_MULTIPLE_CODE { get; set; }
    
    
            [RegularExpression("^[0-9]*$", ErrorMessage = "Only Numberic characters allowed")]  //must be muneric
            [Display(Name="Parent Multiple Code")]
            public int? MULT_LINK_MULTIPLE_CODE { get; set; }   //? menas nullable  ORUG 10/06/19
             //public string MULT_LINK_MULTIPLE_CODE { get; set; }   //? menas nullable  ORUG 10/06/19
    
            [Display(Name= "Channel")]
            public string MULT_JMW_MULTIPLE_TYPE_CODE { get; set; }
            [ForeignKey("MULT_JMW_MULTIPLE_TYPE_CODE")]
            public CHANNELS CHANNELS { get; set; }
    
            public string MULT_AUTH_REQUIRED { get; set; }
            public string MULT_PROM_AUTH_REQUIRED { get; set; }
        }
     
     //       public enum Channel
    //{
     //   IND,
     //   GRO   
    //}
    
    }
    

    index.cshtml.cs

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Threading.Tasks;
    using Microsoft.AspNetCore.Mvc;
    using Microsoft.AspNetCore.Mvc.RazorPages;
    using Microsoft.EntityFrameworkCore;
    using RazorCRUD.Models;
    using RazorCRUD.Paging;
    using Microsoft.AspNetCore.Mvc.Rendering;
    
    namespace RazorCRUD.Pages.MULTIPLES
    {
        public class IndexModel : PageModel
        {
            private readonly RazorCRUD.Models.RazorCRUDContext _context;
    
            public IndexModel(RazorCRUD.Models.RazorCRUDContext context)
            {
                _context = context;
            }
    
             public string NameSort { get; set; }
        public string CodeSort { get; set; }
        public string CurrentFilter { get; set; }
        public string CurrentSort { get; set; }
    
    
            public PaginatedList<MULTIPLE> MULTIPLE { get;set; }
    
                        [BindProperty(SupportsGet = true)]
                    public string SearchString { get; set; }
                    // Requires using Microsoft.AspNetCore.Mvc.Rendering;
                    public SelectList MultipleNames { get; set; }
                    [BindProperty(SupportsGet = true)]
                    public string MULT_NAME { get; set; }
    
            public async Task OnGetAsync(string sortOrder,
                string currentFilter, string searchString, int? pageIndex)
            {
                  
                //MULTIPLES = await _context.MULTIPLE
                
                CurrentSort = sortOrder;
    
                //MULTIPLE = await _context.Movie.ToListAsync();
    
    
                NameSort = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
                CodeSort = sortOrder == "Code" ? "code_desc" : "Code";
                if (searchString != null)
                    {
                        pageIndex = 1;
                    }
                    else
                    {
                        searchString = currentFilter;
                    }
    
                CurrentFilter = searchString;
    
                   // IQueryable<MULTIPLE> multipleIQ = from s in _context.MULTIPLE.Include("CHANNELS")
                    IQueryable<MULTIPLE> multipleIQ = from s in _context.MULTIPLE.Include("CHANNELS")
                                                        select s;
    
                                                       if (!String.IsNullOrEmpty(searchString))
                                                        {
                                                            multipleIQ = multipleIQ.Where(s => s.MULT_NAME.Contains(searchString));
                                                        }
    
    
                        switch (sortOrder)
                        {
                            case "name_desc":
                                multipleIQ = multipleIQ.OrderByDescending(s => s.MULT_NAME);
                                break;
                            case "Code":
                                multipleIQ = multipleIQ.OrderBy(s => s.MULT_MULTIPLE_CODE);
                                break;
                            case "code_desc":
                                multipleIQ = multipleIQ.OrderByDescending(s => s.MULT_MULTIPLE_CODE);
                                break;
                            default:
                                multipleIQ = multipleIQ.OrderBy(s => s.MULT_NAME);
                                break;
                        }
    
                         int pageSize = 50;
                            MULTIPLE = await PaginatedList<MULTIPLE>.CreateAsync(
                            multipleIQ.AsNoTracking(), pageIndex ?? 1, pageSize);
    
    
    //MULTIPLE = await _context.MULTIPLE
                    //.Include(c => c.CHANNELS)
                   // .AsNoTracking()
                   // .ToListAsync();
                             //.Include(c => c.CHANNELS);
    
                             //ChannelTypes = new SelectList(_context.Channel_Types, "Channel_Type_Code", "Channel_Type_Name");//added 21/05/19
    
                      //  MULTIPLE = await multipleIQ.AsNoTracking().ToListAsync(); commented out 10/05/2019
    
    
                         //   var mlist = from m in _context.MULTIPLE
                         //   select m;
                         //   if (!string.IsNullOrEmpty(SearchString))
                         //   {
                         //       mlist = mlist.Where(s => s.MULT_NAME.Contains(SearchString));
                         //   }
    
                      // MULTIPLE = await mlist.ToListAsync();
                //MULTIPLE = await _context.mlist.ToListAsync();
            }
    
    
        }
    }
    

    index.cshtml

    @page
    @model RazorCRUD.Pages.MULTIPLES.IndexModel
    
    @{
        ViewData["Title"] = "Index";
    }
    
    <h2>Maintain Multiple Index</h2>
    
    <p>
        <a asp-page="Create">Create New</a>
    </p>
    
    <!--form>
        <p>
            Multiple Name: <input type="text" asp-for="SearchString" />
            <input type="submit" value="Filter" />
        </p>
    </form-->
    
    <form asp-page="./Index" method="get">
        <div class="form-actions no-color">
            <p>
                Find by name:
                <input type="text" name="SearchString" value="@Model.CurrentFilter" />
                <input type="submit" value="Search" class="btn btn-default" /> |
                <a asp-page="./Index">Back to full List</a>
            </p>
        </div>
    </form>
    
    <table class="table table-striped">
        <thead>
            <tr>
                
                <th>
                    <a asp-page="./Index" asp-route-sortOrder="@Model.CodeSort"
                       asp-route-currentFilter="@Model.CurrentFilter">
                        @Html.DisplayNameFor(model => model.MULTIPLE[0].MULT_MULTIPLE_CODE)
                    </a>
                </th>     
                <th>
                    <a asp-page="./Index" asp-route-sortOrder="@Model.NameSort"
                       asp-route-currentFilter="@Model.CurrentFilter">
                        @Html.DisplayNameFor(model => model.MULTIPLE[0].MULT_NAME)
                    </a>
                </th>
                @* <th>
                    @Html.DisplayNameFor(model => model.MULTIPLE[0].MULT_SELECTED_MULTIPLE)
                </th>*@ 
                <th>
                    @Html.DisplayNameFor(model => model.MULTIPLE[0].MULT_ANMW_MULTIPLE_CODE)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.MULTIPLE[0].MULT_LINK_MULTIPLE_CODE)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.MULTIPLE[0].MULT_JMW_MULTIPLE_TYPE_CODE)
                </th>
                @* <th>
                    @Html.DisplayNameFor(model => model.MULTIPLE[0].MULT_AUTH_REQUIRED)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.MULTIPLE[0].MULT_PROM_AUTH_REQUIRED)
                </th>*@ 
                <th></th>
            </tr>
        </thead>
        <tbody>
    @foreach (var item in Model.MULTIPLE) {
            <tr>
                <td>
                    @Html.DisplayFor(modelItem => item.MULT_MULTIPLE_CODE)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.MULT_NAME)
                </td>
                @* <td>
                    @Html.DisplayFor(modelItem => item.MULT_SELECTED_MULTIPLE)
                </td> *@
                <td>
                    @Html.DisplayFor(modelItem => item.MULT_ANMW_MULTIPLE_CODE)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.MULT_LINK_MULTIPLE_CODE)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.CHANNELS.CHA_NAME)
                </td>
                @*<td>
                    @Html.DisplayFor(modelItem => item.MULT_AUTH_REQUIRED)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.MULT_PROM_AUTH_REQUIRED)
                </td> *@
                <td>
                    <a asp-page="./Edit" asp-route-id="@item.MULT_MULTIPLE_CODE">Edit</a> |
                    <a asp-page="./Details" asp-route-id="@item.MULT_MULTIPLE_CODE">Details</a> |
                    <a asp-page="./Delete" asp-route-id="@item.MULT_MULTIPLE_CODE">Delete</a>
                </td>
            </tr>
    }
        </tbody>
    </table>
    @{
        var prevDisabled = !Model.MULTIPLE.HasPreviousPage ? "disabled" : "";
        var nextDisabled = !Model.MULTIPLE.HasNextPage ? "disabled" : "";
    }
    <a asp-page="./Index"
       asp-route-sortOrder="@Model.CurrentSort"
       asp-route-pageIndex="@(Model.MULTIPLE.PageIndex - 1)"
       asp-route-currentFilter="@Model.CurrentFilter"
       class="btn btn-default @prevDisabled">
        Previous
    </a>
    <a asp-page="./Index"
       asp-route-sortOrder="@Model.CurrentSort"
       asp-route-pageIndex="@(Model.MULTIPLE.PageIndex + 1)"
       asp-route-currentFilter="@Model.CurrentFilter"
       class="btn btn-default @nextDisabled">
        Next
    </a>
    

    Tuesday, September 10, 2019 9:24 AM
  • User711641945 posted

    Hi poR,

    but still doesn't sort after entering search string and displays no rows.

    You mean that you could not get the data when you enter the search string?Please check if you have these data in your database.I have displayed successfully.

    You need to modify the following code:

    NameSort = String.IsNullOrEmpty(sortOrder) ? "" : "name_desc";
    CodeSort = sortOrder == "Code" ? "Code" : "code_desc";

    Result:

    Best Regards,

    Rena

    Tuesday, September 10, 2019 9:59 AM
  • User915516305 posted

    Hi Rena,

    Thanks for reply.

    Tried changing the 2 lines you suggested but still no joy.

    I can get data to display pressing search but when click the code or name hyperlink after this expect those rows to be sorted in name or code order but instead just shows no rows.

    Any other thoughts?

    Thanks

    Tuesday, September 10, 2019 10:07 AM
  • User711641945 posted

    Hi poR,

    I have already tested by using your whole code and it works well. I suggest that you could refer to my project here or share a demo on ondrive which could reproduce your issue.Also,you could set breakpoint to test step by step.

    Notes:If you share your project on ondrive,you need to pay attention to preventing privacy leaks.

    Best Regards,

    Rena

    Wednesday, September 11, 2019 9:03 AM
  • User915516305 posted

    Hi Rena,

    Thanks for reply.

    I can't access your project - says not set up for sharepoint - we don't have this yet.

    In the maintain multiple index screen you have where you have searched for f.  If you then select the code or name hyperlink does it sort correctly?

    It is at this point where after clicking any of those hyperlinks we get the no rows returning. 

    Are you able to share your project another way?

    Thanks

    Wednesday, September 11, 2019 9:53 AM
  • User915516305 posted

    Hi Rena,

    Could you put your project on github?

    If manually put URL as below i.e. searchString behaves as expected i.e. sorts by Code and shows Multiples starting ASD 

    https://localhost:5001/?sortOrder=Code&searchString=ASD

    However, the default url which puts currentFilter when search then try sort doesn't display any rows

    https://localhost:5001/?sortOrder=Code&currentFilter=ASD

    Any ideas why this is the case?

    Thanks

    Thursday, September 12, 2019 8:50 AM
  • User711641945 posted

    Hi poR,

    I have uploaded my project on github here.

    Best Regards,

    Rena

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 12, 2019 9:31 AM
  • User915516305 posted

    Hi Rena,

    Thanks for that.

    Had a look through and notice you are using sql server - using oracle here in this case but wouldn't expect that to be any different 

    If manually put URL as below i.e. searchString behaves as expected i.e. sorts by Code and shows Multiples starting ASD 

    https://localhost:5001/?sortOrder=Code&searchString=ASD

    However, the default url which puts currentFilter when search then try sort doesn't display any rows

    https://localhost:5001/?sortOrder=Code&currentFilter=ASD

    Any ideas why this is the case?

    If you do a search first (e.g. for f) and then look to apply a sort after search does yours work and what does the url show?

    Thanks

    Thursday, September 12, 2019 10:27 AM
  • User915516305 posted

    Hi Rena,

    managed to get sort and filter working together working on dev with help of code you posted on github

    • thanks
    Thursday, September 12, 2019 3:57 PM