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;
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
add a comment |
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
add a comment |
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
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
asp.net-mvc-5 entity-framework-6
asked Mar 23 at 9:55
microchefmicrochef
398
398
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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));
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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));
add a comment |
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));
add a comment |
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));
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));
answered Mar 23 at 11:11
microchefmicrochef
398
398
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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