c# - .Net MVC not sorting -


i'm trying follow microsoft's tutorials on sorting .net mvc5, , while filtering working fine, sorting not.

public actionresult index(string searchstring, string currentfilter, string numberperpage, string submit, int? page)     {         int pagesize = string.isnullorempty(numberperpage) ? 10 : int32.parse(numberperpage);         int pagenumber = (page ?? 1);          var cohortlist = s in db.cohorts select s;         if (((!string.isnullorempty(searchstring)) || (!string.isnullorempty(currentfilter))) && (!string.isnullorempty(submit)))         {             if (searchstring != null)             {                 page = 1;             }             else             {                 searchstring = currentfilter;             }             viewbag.currentfilter = searchstring;             viewbag.numberperpage = numberperpage;             switch (submit)             {                 case "conceptsearch":                     var conceptresults = cohortlist.where(s => s.overview.contains(searchstring)).orderby(s => s.name);                     if (conceptresults.count() > 0)                     {                         viewbag.searchterm = searchstring;                         viewbag.submit = submit;                         return view(conceptresults.topagedlist(pagenumber, pagesize));                     }                     else                     {                         viewbag.searchterm = searchstring;                         viewbag.submit = submit;                         return view(conceptresults.topagedlist(pagenumber, pagesize));                     }                     //break;                 case "textsearch":                     var textresults = cohortlist.where(s => s.overview.contains(searchstring)).orderby(s => s.name);                     if (textresults.count() > 0)                     {                         viewbag.searchterm = searchstring;                         viewbag.submit = submit;                         return view(textresults.topagedlist(pagenumber, pagesize));                     }                     else                     {                         viewbag.searchterm = searchstring;                         viewbag.submit = submit;                         return view(textresults.topagedlist(pagenumber, pagesize));                     }                     //break;             }         }         return view(cohortlist.topagedlist(pagenumber, pagesize));     } 

the paging works fine, returns list sorted id , not name.


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -