Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 112117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:29:39+00:00 2026-05-11T02:29:39+00:00

I’m working on a basic Issue Management System in order to learn ASP.NET MVC.

  • 0

I’m working on a basic Issue Management System in order to learn ASP.NET MVC. I’ve gotten it up and running to a fairly decent level but I’ve run into a problem.

I have a controller named Issue with a view called Open. /Issue/Open lists all of the open issues currently logged on the system. I’ve defined a route like so:

    routes.MapRoute(          'OpenSort',                                                         // Route name         'Issue/Open/{sort}',                                                // URL with parameters         new { controller = 'Issue', action = 'Open', sort = 'TimeLogged' }  // Parameter defaults     ); 

This is working fine so far, using the following code in IssueController.cs:

public ActionResult Open(string sort) {                 var Issues = from i in db.Issues where i.Status == 'Open' orderby i.TimeLogged ascending select i;      switch (sort)     {         case 'ID':             Issues = from i in db.Issues where i.Status == 'Open' orderby i.ID ascending select i;             break;          case 'TimeLogged':             goto default;          case 'Technician':             Issues = from i in db.Issues where i.Status == 'Open' orderby i.Technician ascending select i;             break;          case 'Customer':             Issues = from i in db.Issues where i.Status == 'Open' orderby i.Customer ascending select i;             break;          case 'Category':             Issues = from i in db.Issues where i.Status == 'Open' orderby i.Category ascending select i;             break;          case 'Priority':             Issues = from i in db.Issues where i.Status == 'Open' orderby i.Priority ascending select i;             break;          case 'Status':             Issues = from i in db.Issues where i.Status == 'Open' orderby i.Status ascending select i;             break;          default:             break;     }                  ViewData['Title'] = 'Open Issues';     ViewData['SortID'] = sort.ToString();      return View(Issues.ToList()); } 

This is working fine (although, I wonder if there is a better way to handle my definition of the query than a switch?) but now I want to be able to do two things on the Open Issues view:

  1. Sort by any of the headings – OK
  2. Filter on certain headings (Technician, Customer, Category, Priority, Status) – ??

I can’t figure out how to pass two parameters to the Controller so I can organise my queries. I’ve also just realised that unless I figure out how to generate my queries on the fly I am going to need (number of sort options) * (number of filter options) in my switch.

Argh, can anyone point me in the right direction? Cheers!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T02:29:39+00:00Added an answer on May 11, 2026 at 2:29 am
    1. Remove sort from the route. Just use a route without a parameter.
    2. Add query string parameters to the query for the sort, filter, etc. So your query will look like:

    http://example.com/Issue/Open?sort=ID&filter=foo

    public ActionResult Open(string sort, string filter) 

    The MVC framework will fill in the arguments from the query string parameters. Make sure and use nullable types (like string) for any of these query string parameter arguments which might not be filled in.

    I actually think this is a ‘more correct’ way to write the URL. The URL itself identifies the resource (open issues); the query string parameters customize how to display the resource.

    As far as the number of queries go, remember that you do not have to build the entire query at once. You can use the .OrderBy extension method to re-order an existing IQueryable<T>, and similarly with .Where.

    var Issues = from i in db.Issues where i.Status == 'Open' select i;  switch (sort) {     case 'ID':         Issues = Issues.OrderBy(i => i.ID);         break;      // [...]      default:         Issues = Issues.OrderBy(i => i.TimeLogged); }      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 94k
  • Answers 94k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Have the SWF make an ExternalInterface call to resize itself… May 11, 2026 at 6:46 pm
  • Editorial Team
    Editorial Team added an answer You are going to need a Paypal Business account to… May 11, 2026 at 6:46 pm
  • Editorial Team
    Editorial Team added an answer Levinshtein is relevant, but will not give you a value… May 11, 2026 at 6:46 pm

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.