How to use multiple sort orders in controllerHow to create a checkbox list?how can i fill controller with data - SQL Function in Entity Framework?Randomize loading order of productsI cant get this form to send email or redirect to the correct viewFile upload in MVC 5 when used in bootstrap modal returns nullmvc form submits as get instead of postHow to access viewModel in controllermodifying main view from inside partial viewWhy is a DateTime field always written as ZERO in my WPF app with EF6?How to display individual records in view (when stored in variable that uses lambda in controller)

Company stopped paying my salary. What are my options?

How to efficiently lower your karma

Extending Kan fibrations, without using minimal fibrations

Is every story set in the future "science fiction"?

Why was wildfire not used during the Battle of Winterfell?

spatiotemporal regression

What does this quote in Small Gods refer to?

Was Mohammed the most popular first name for boys born in Berlin in 2018?

Why should password hash verification be time constant?

What was the notion of limit that Newton used?

What's the "magic similar to the Knock spell" referenced in the Dungeon of the Mad Mage adventure?

Are there variations of the regular runtimes of the Big-O-Notation?

Is it a Munchausen Number?

Pre-1993 comic in which Wolverine's claws were turned to rubber?

cropping a message using array splits

Are there non-military uses of 20%-enriched Uranium?

How to slow yourself down (for playing nice with others)

Thesis' "Future Work" section – is it acceptable to omit personal involvement in a mentioned project?

Intersecting with the x-axis / intersecting the x-axis

Can 'sudo apt-get remove [write]' destroy my Ubuntu?

When do you stop "pushing" a book?

How to get a ellipse shaped node in Tikz Network?

Passport stamps art, can it be done?

How is CoreiX like Corei5, i7 is related to Haswell, Ivy Bridge?



How to use multiple sort orders in controller


How to create a checkbox list?how can i fill controller with data - SQL Function in Entity Framework?Randomize loading order of productsI cant get this form to send email or redirect to the correct viewFile upload in MVC 5 when used in bootstrap modal returns nullmvc form submits as get instead of postHow to access viewModel in controllermodifying main view from inside partial viewWhy is a DateTime field always written as ZERO in my WPF app with EF6?How to display individual records in view (when stored in variable that uses lambda in controller)






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I have multiple sortorder's list in an controller for 3 pages however when i sort on a table not in an index page. I am returned to the Index Page.



I thought changing the sortorder naming to make it different would work.



 public async Task<ActionResult> DashBoard(string sortOrder, string currentFilter,string searchString, int? page)

ViewBag.CurrentSort = sortOrder;
ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
ViewBag.DateSortParm = sortOrder == "Date" ? "date_desc" : "Date";

if (searchString != null)

page = 1;

else

searchString = currentFilter;


ViewBag.CurrentFilter = searchString;

var clinicalAssets = from s in db.ClinicalAssets.Include(c => c.ModelName) select s;

if (!String.IsNullOrEmpty(searchString))


switch (sortOrder)

case "name_desc":
clinicalAssets = clinicalAssets.OrderByDescending(s => s.PoNo);
break;
case "Date":
clinicalAssets = clinicalAssets.OrderBy(s => s.PurchaseDate);
break;
case "date_desc":
clinicalAssets = clinicalAssets.OrderByDescending(s => s.WarrantyEndDate);
break;
default:
clinicalAssets = clinicalAssets.OrderBy(s => s.ClinicalAssetID);
break;

int pageSize = 10;
int pageNumber = (page ?? 1);
return View(await clinicalAssets.ToPagedListAsync(pageNumber, pageSize));



public async Task<ActionResult> Arjo(string sortOrder2, string currentFilter2, string searchString2, int? page)
s.AssetTypeID.Equals(3) )
select s;



if (!String.IsNullOrEmpty(searchString2))
s.PoNo.Contains(searchString2));




switch (sortOrder2)

case "name_desc":
clinicalAssets = clinicalAssets.OrderByDescending(s => s.PoNo);
break;
case "Date":
clinicalAssets = clinicalAssets.OrderBy(s => s.PurchaseDate);
break;
case "date_desc":
clinicalAssets = clinicalAssets.OrderByDescending(s => s.WarrantyEndDate);
break;
default:
clinicalAssets = clinicalAssets.OrderBy(s => s.ClinicalAssetID);
break;

int pageSize = 10;
int pageNumber = (page ?? 1);
return View(await clinicalAssets.ToPagedListAsync(pageNumber, pageSize));


public async Task<ActionResult> Index(string sortOrder1, string currentFilter1, string searchString1, int? page)

ViewBag.CurrentSort = sortOrder1;
ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder1) ? "name_desc" : "";
ViewBag.DateSortParm = sortOrder1 == "Date" ? "date_desc" : "Date";

if (searchString1 != null)

page = 1;

else

searchString1 = currentFilter1;


ViewBag.CurrentFilter = searchString1;

var clinicalAssets = from s in db.ClinicalAssets.Include(c => c.ModelName) select s;

if (!String.IsNullOrEmpty(searchString1))
s.PoNo.Contains(searchString1));


switch (sortOrder1)

case "name_desc":
clinicalAssets = clinicalAssets.OrderByDescending(s => s.PoNo);
break;
case "Date":
clinicalAssets = clinicalAssets.OrderBy(s => s.PurchaseDate);
break;
case "date_desc":
clinicalAssets = clinicalAssets.OrderByDescending(s => s.WarrantyEndDate);
break;
default:
clinicalAssets = clinicalAssets.OrderBy(s => s.ClinicalAssetID);
break;

int pageSize = 10;
int pageNumber = (page ?? 1);
return View(await clinicalAssets.ToPagedListAsync(pageNumber, pageSize));



I would have expected to see each page filter its own table not tables of other pages.










share|improve this question




























    0















    I have multiple sortorder's list in an controller for 3 pages however when i sort on a table not in an index page. I am returned to the Index Page.



    I thought changing the sortorder naming to make it different would work.



     public async Task<ActionResult> DashBoard(string sortOrder, string currentFilter,string searchString, int? page)

    ViewBag.CurrentSort = sortOrder;
    ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
    ViewBag.DateSortParm = sortOrder == "Date" ? "date_desc" : "Date";

    if (searchString != null)

    page = 1;

    else

    searchString = currentFilter;


    ViewBag.CurrentFilter = searchString;

    var clinicalAssets = from s in db.ClinicalAssets.Include(c => c.ModelName) select s;

    if (!String.IsNullOrEmpty(searchString))


    switch (sortOrder)

    case "name_desc":
    clinicalAssets = clinicalAssets.OrderByDescending(s => s.PoNo);
    break;
    case "Date":
    clinicalAssets = clinicalAssets.OrderBy(s => s.PurchaseDate);
    break;
    case "date_desc":
    clinicalAssets = clinicalAssets.OrderByDescending(s => s.WarrantyEndDate);
    break;
    default:
    clinicalAssets = clinicalAssets.OrderBy(s => s.ClinicalAssetID);
    break;

    int pageSize = 10;
    int pageNumber = (page ?? 1);
    return View(await clinicalAssets.ToPagedListAsync(pageNumber, pageSize));



    public async Task<ActionResult> Arjo(string sortOrder2, string currentFilter2, string searchString2, int? page)
    s.AssetTypeID.Equals(3) )
    select s;



    if (!String.IsNullOrEmpty(searchString2))
    s.PoNo.Contains(searchString2));




    switch (sortOrder2)

    case "name_desc":
    clinicalAssets = clinicalAssets.OrderByDescending(s => s.PoNo);
    break;
    case "Date":
    clinicalAssets = clinicalAssets.OrderBy(s => s.PurchaseDate);
    break;
    case "date_desc":
    clinicalAssets = clinicalAssets.OrderByDescending(s => s.WarrantyEndDate);
    break;
    default:
    clinicalAssets = clinicalAssets.OrderBy(s => s.ClinicalAssetID);
    break;

    int pageSize = 10;
    int pageNumber = (page ?? 1);
    return View(await clinicalAssets.ToPagedListAsync(pageNumber, pageSize));


    public async Task<ActionResult> Index(string sortOrder1, string currentFilter1, string searchString1, int? page)

    ViewBag.CurrentSort = sortOrder1;
    ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder1) ? "name_desc" : "";
    ViewBag.DateSortParm = sortOrder1 == "Date" ? "date_desc" : "Date";

    if (searchString1 != null)

    page = 1;

    else

    searchString1 = currentFilter1;


    ViewBag.CurrentFilter = searchString1;

    var clinicalAssets = from s in db.ClinicalAssets.Include(c => c.ModelName) select s;

    if (!String.IsNullOrEmpty(searchString1))
    s.PoNo.Contains(searchString1));


    switch (sortOrder1)

    case "name_desc":
    clinicalAssets = clinicalAssets.OrderByDescending(s => s.PoNo);
    break;
    case "Date":
    clinicalAssets = clinicalAssets.OrderBy(s => s.PurchaseDate);
    break;
    case "date_desc":
    clinicalAssets = clinicalAssets.OrderByDescending(s => s.WarrantyEndDate);
    break;
    default:
    clinicalAssets = clinicalAssets.OrderBy(s => s.ClinicalAssetID);
    break;

    int pageSize = 10;
    int pageNumber = (page ?? 1);
    return View(await clinicalAssets.ToPagedListAsync(pageNumber, pageSize));



    I would have expected to see each page filter its own table not tables of other pages.










    share|improve this question
























      0












      0








      0








      I have multiple sortorder's list in an controller for 3 pages however when i sort on a table not in an index page. I am returned to the Index Page.



      I thought changing the sortorder naming to make it different would work.



       public async Task<ActionResult> DashBoard(string sortOrder, string currentFilter,string searchString, int? page)

      ViewBag.CurrentSort = sortOrder;
      ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
      ViewBag.DateSortParm = sortOrder == "Date" ? "date_desc" : "Date";

      if (searchString != null)

      page = 1;

      else

      searchString = currentFilter;


      ViewBag.CurrentFilter = searchString;

      var clinicalAssets = from s in db.ClinicalAssets.Include(c => c.ModelName) select s;

      if (!String.IsNullOrEmpty(searchString))


      switch (sortOrder)

      case "name_desc":
      clinicalAssets = clinicalAssets.OrderByDescending(s => s.PoNo);
      break;
      case "Date":
      clinicalAssets = clinicalAssets.OrderBy(s => s.PurchaseDate);
      break;
      case "date_desc":
      clinicalAssets = clinicalAssets.OrderByDescending(s => s.WarrantyEndDate);
      break;
      default:
      clinicalAssets = clinicalAssets.OrderBy(s => s.ClinicalAssetID);
      break;

      int pageSize = 10;
      int pageNumber = (page ?? 1);
      return View(await clinicalAssets.ToPagedListAsync(pageNumber, pageSize));



      public async Task<ActionResult> Arjo(string sortOrder2, string currentFilter2, string searchString2, int? page)
      s.AssetTypeID.Equals(3) )
      select s;



      if (!String.IsNullOrEmpty(searchString2))
      s.PoNo.Contains(searchString2));




      switch (sortOrder2)

      case "name_desc":
      clinicalAssets = clinicalAssets.OrderByDescending(s => s.PoNo);
      break;
      case "Date":
      clinicalAssets = clinicalAssets.OrderBy(s => s.PurchaseDate);
      break;
      case "date_desc":
      clinicalAssets = clinicalAssets.OrderByDescending(s => s.WarrantyEndDate);
      break;
      default:
      clinicalAssets = clinicalAssets.OrderBy(s => s.ClinicalAssetID);
      break;

      int pageSize = 10;
      int pageNumber = (page ?? 1);
      return View(await clinicalAssets.ToPagedListAsync(pageNumber, pageSize));


      public async Task<ActionResult> Index(string sortOrder1, string currentFilter1, string searchString1, int? page)

      ViewBag.CurrentSort = sortOrder1;
      ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder1) ? "name_desc" : "";
      ViewBag.DateSortParm = sortOrder1 == "Date" ? "date_desc" : "Date";

      if (searchString1 != null)

      page = 1;

      else

      searchString1 = currentFilter1;


      ViewBag.CurrentFilter = searchString1;

      var clinicalAssets = from s in db.ClinicalAssets.Include(c => c.ModelName) select s;

      if (!String.IsNullOrEmpty(searchString1))
      s.PoNo.Contains(searchString1));


      switch (sortOrder1)

      case "name_desc":
      clinicalAssets = clinicalAssets.OrderByDescending(s => s.PoNo);
      break;
      case "Date":
      clinicalAssets = clinicalAssets.OrderBy(s => s.PurchaseDate);
      break;
      case "date_desc":
      clinicalAssets = clinicalAssets.OrderByDescending(s => s.WarrantyEndDate);
      break;
      default:
      clinicalAssets = clinicalAssets.OrderBy(s => s.ClinicalAssetID);
      break;

      int pageSize = 10;
      int pageNumber = (page ?? 1);
      return View(await clinicalAssets.ToPagedListAsync(pageNumber, pageSize));



      I would have expected to see each page filter its own table not tables of other pages.










      share|improve this question














      I have multiple sortorder's list in an controller for 3 pages however when i sort on a table not in an index page. I am returned to the Index Page.



      I thought changing the sortorder naming to make it different would work.



       public async Task<ActionResult> DashBoard(string sortOrder, string currentFilter,string searchString, int? page)

      ViewBag.CurrentSort = sortOrder;
      ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
      ViewBag.DateSortParm = sortOrder == "Date" ? "date_desc" : "Date";

      if (searchString != null)

      page = 1;

      else

      searchString = currentFilter;


      ViewBag.CurrentFilter = searchString;

      var clinicalAssets = from s in db.ClinicalAssets.Include(c => c.ModelName) select s;

      if (!String.IsNullOrEmpty(searchString))


      switch (sortOrder)

      case "name_desc":
      clinicalAssets = clinicalAssets.OrderByDescending(s => s.PoNo);
      break;
      case "Date":
      clinicalAssets = clinicalAssets.OrderBy(s => s.PurchaseDate);
      break;
      case "date_desc":
      clinicalAssets = clinicalAssets.OrderByDescending(s => s.WarrantyEndDate);
      break;
      default:
      clinicalAssets = clinicalAssets.OrderBy(s => s.ClinicalAssetID);
      break;

      int pageSize = 10;
      int pageNumber = (page ?? 1);
      return View(await clinicalAssets.ToPagedListAsync(pageNumber, pageSize));



      public async Task<ActionResult> Arjo(string sortOrder2, string currentFilter2, string searchString2, int? page)
      s.AssetTypeID.Equals(3) )
      select s;



      if (!String.IsNullOrEmpty(searchString2))
      s.PoNo.Contains(searchString2));




      switch (sortOrder2)

      case "name_desc":
      clinicalAssets = clinicalAssets.OrderByDescending(s => s.PoNo);
      break;
      case "Date":
      clinicalAssets = clinicalAssets.OrderBy(s => s.PurchaseDate);
      break;
      case "date_desc":
      clinicalAssets = clinicalAssets.OrderByDescending(s => s.WarrantyEndDate);
      break;
      default:
      clinicalAssets = clinicalAssets.OrderBy(s => s.ClinicalAssetID);
      break;

      int pageSize = 10;
      int pageNumber = (page ?? 1);
      return View(await clinicalAssets.ToPagedListAsync(pageNumber, pageSize));


      public async Task<ActionResult> Index(string sortOrder1, string currentFilter1, string searchString1, int? page)

      ViewBag.CurrentSort = sortOrder1;
      ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder1) ? "name_desc" : "";
      ViewBag.DateSortParm = sortOrder1 == "Date" ? "date_desc" : "Date";

      if (searchString1 != null)

      page = 1;

      else

      searchString1 = currentFilter1;


      ViewBag.CurrentFilter = searchString1;

      var clinicalAssets = from s in db.ClinicalAssets.Include(c => c.ModelName) select s;

      if (!String.IsNullOrEmpty(searchString1))
      s.PoNo.Contains(searchString1));


      switch (sortOrder1)

      case "name_desc":
      clinicalAssets = clinicalAssets.OrderByDescending(s => s.PoNo);
      break;
      case "Date":
      clinicalAssets = clinicalAssets.OrderBy(s => s.PurchaseDate);
      break;
      case "date_desc":
      clinicalAssets = clinicalAssets.OrderByDescending(s => s.WarrantyEndDate);
      break;
      default:
      clinicalAssets = clinicalAssets.OrderBy(s => s.ClinicalAssetID);
      break;

      int pageSize = 10;
      int pageNumber = (page ?? 1);
      return View(await clinicalAssets.ToPagedListAsync(pageNumber, pageSize));



      I would have expected to see each page filter its own table not tables of other pages.







      asp.net-mvc-5 entity-framework-6






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 23 at 9:55









      microchefmicrochef

      398




      398






















          1 Answer
          1






          active

          oldest

          votes


















          0














          I was on the right track, i also needed to update the @html.Actionlink and the sortParm.



           public async Task<ActionResult> Index(string sortOrder1, string currentFilter1, string searchString1, int? page1)

          ViewBag.CurrentSort1 = sortOrder1;
          ViewBag.NameSortParm1 = String.IsNullOrEmpty(sortOrder1) ? "name_desc" : "";
          ViewBag.DateSortParm1 = sortOrder1 == "Date" ? "date_desc" : "Date";

          if (searchString1 != null)

          page1 = 1;

          else

          searchString1 = currentFilter1;


          ViewBag.CurrentFilter1 = searchString1;

          var clinicalAssets = from s in db.ClinicalAssets.Include(c => c.ModelName) select s;

          if (!String.IsNullOrEmpty(searchString1))
          s.PoNo.Contains(searchString1));


          switch (sortOrder1)

          case "name_desc":
          clinicalAssets = clinicalAssets.OrderByDescending(s => s.PoNo);
          break;
          case "Date":
          clinicalAssets = clinicalAssets.OrderBy(s => s.PurchaseDate);
          break;
          case "date_desc":
          clinicalAssets = clinicalAssets.OrderByDescending(s => s.WarrantyEndDate);
          break;
          default:
          clinicalAssets = clinicalAssets.OrderBy(s => s.ClinicalAssetID);
          break;

          int pageSize = 10;
          int pageNumber = (page1 ?? 1);
          return View(await clinicalAssets.ToPagedListAsync(pageNumber, pageSize));






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55312529%2fhow-to-use-multiple-sort-orders-in-controller%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            I was on the right track, i also needed to update the @html.Actionlink and the sortParm.



             public async Task<ActionResult> Index(string sortOrder1, string currentFilter1, string searchString1, int? page1)

            ViewBag.CurrentSort1 = sortOrder1;
            ViewBag.NameSortParm1 = String.IsNullOrEmpty(sortOrder1) ? "name_desc" : "";
            ViewBag.DateSortParm1 = sortOrder1 == "Date" ? "date_desc" : "Date";

            if (searchString1 != null)

            page1 = 1;

            else

            searchString1 = currentFilter1;


            ViewBag.CurrentFilter1 = searchString1;

            var clinicalAssets = from s in db.ClinicalAssets.Include(c => c.ModelName) select s;

            if (!String.IsNullOrEmpty(searchString1))
            s.PoNo.Contains(searchString1));


            switch (sortOrder1)

            case "name_desc":
            clinicalAssets = clinicalAssets.OrderByDescending(s => s.PoNo);
            break;
            case "Date":
            clinicalAssets = clinicalAssets.OrderBy(s => s.PurchaseDate);
            break;
            case "date_desc":
            clinicalAssets = clinicalAssets.OrderByDescending(s => s.WarrantyEndDate);
            break;
            default:
            clinicalAssets = clinicalAssets.OrderBy(s => s.ClinicalAssetID);
            break;

            int pageSize = 10;
            int pageNumber = (page1 ?? 1);
            return View(await clinicalAssets.ToPagedListAsync(pageNumber, pageSize));






            share|improve this answer



























              0














              I was on the right track, i also needed to update the @html.Actionlink and the sortParm.



               public async Task<ActionResult> Index(string sortOrder1, string currentFilter1, string searchString1, int? page1)

              ViewBag.CurrentSort1 = sortOrder1;
              ViewBag.NameSortParm1 = String.IsNullOrEmpty(sortOrder1) ? "name_desc" : "";
              ViewBag.DateSortParm1 = sortOrder1 == "Date" ? "date_desc" : "Date";

              if (searchString1 != null)

              page1 = 1;

              else

              searchString1 = currentFilter1;


              ViewBag.CurrentFilter1 = searchString1;

              var clinicalAssets = from s in db.ClinicalAssets.Include(c => c.ModelName) select s;

              if (!String.IsNullOrEmpty(searchString1))
              s.PoNo.Contains(searchString1));


              switch (sortOrder1)

              case "name_desc":
              clinicalAssets = clinicalAssets.OrderByDescending(s => s.PoNo);
              break;
              case "Date":
              clinicalAssets = clinicalAssets.OrderBy(s => s.PurchaseDate);
              break;
              case "date_desc":
              clinicalAssets = clinicalAssets.OrderByDescending(s => s.WarrantyEndDate);
              break;
              default:
              clinicalAssets = clinicalAssets.OrderBy(s => s.ClinicalAssetID);
              break;

              int pageSize = 10;
              int pageNumber = (page1 ?? 1);
              return View(await clinicalAssets.ToPagedListAsync(pageNumber, pageSize));






              share|improve this answer

























                0












                0








                0







                I was on the right track, i also needed to update the @html.Actionlink and the sortParm.



                 public async Task<ActionResult> Index(string sortOrder1, string currentFilter1, string searchString1, int? page1)

                ViewBag.CurrentSort1 = sortOrder1;
                ViewBag.NameSortParm1 = String.IsNullOrEmpty(sortOrder1) ? "name_desc" : "";
                ViewBag.DateSortParm1 = sortOrder1 == "Date" ? "date_desc" : "Date";

                if (searchString1 != null)

                page1 = 1;

                else

                searchString1 = currentFilter1;


                ViewBag.CurrentFilter1 = searchString1;

                var clinicalAssets = from s in db.ClinicalAssets.Include(c => c.ModelName) select s;

                if (!String.IsNullOrEmpty(searchString1))
                s.PoNo.Contains(searchString1));


                switch (sortOrder1)

                case "name_desc":
                clinicalAssets = clinicalAssets.OrderByDescending(s => s.PoNo);
                break;
                case "Date":
                clinicalAssets = clinicalAssets.OrderBy(s => s.PurchaseDate);
                break;
                case "date_desc":
                clinicalAssets = clinicalAssets.OrderByDescending(s => s.WarrantyEndDate);
                break;
                default:
                clinicalAssets = clinicalAssets.OrderBy(s => s.ClinicalAssetID);
                break;

                int pageSize = 10;
                int pageNumber = (page1 ?? 1);
                return View(await clinicalAssets.ToPagedListAsync(pageNumber, pageSize));






                share|improve this answer













                I was on the right track, i also needed to update the @html.Actionlink and the sortParm.



                 public async Task<ActionResult> Index(string sortOrder1, string currentFilter1, string searchString1, int? page1)

                ViewBag.CurrentSort1 = sortOrder1;
                ViewBag.NameSortParm1 = String.IsNullOrEmpty(sortOrder1) ? "name_desc" : "";
                ViewBag.DateSortParm1 = sortOrder1 == "Date" ? "date_desc" : "Date";

                if (searchString1 != null)

                page1 = 1;

                else

                searchString1 = currentFilter1;


                ViewBag.CurrentFilter1 = searchString1;

                var clinicalAssets = from s in db.ClinicalAssets.Include(c => c.ModelName) select s;

                if (!String.IsNullOrEmpty(searchString1))
                s.PoNo.Contains(searchString1));


                switch (sortOrder1)

                case "name_desc":
                clinicalAssets = clinicalAssets.OrderByDescending(s => s.PoNo);
                break;
                case "Date":
                clinicalAssets = clinicalAssets.OrderBy(s => s.PurchaseDate);
                break;
                case "date_desc":
                clinicalAssets = clinicalAssets.OrderByDescending(s => s.WarrantyEndDate);
                break;
                default:
                clinicalAssets = clinicalAssets.OrderBy(s => s.ClinicalAssetID);
                break;

                int pageSize = 10;
                int pageNumber = (page1 ?? 1);
                return View(await clinicalAssets.ToPagedListAsync(pageNumber, pageSize));







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 23 at 11:11









                microchefmicrochef

                398




                398





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55312529%2fhow-to-use-multiple-sort-orders-in-controller%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                    은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현