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 9010743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:32:40+00:00 2026-06-16T02:32:40+00:00

I’m trying to sort my result page (which is in another view than the

  • 0

I’m trying to sort my result page (which is in another view than the filtration page). I have faced this weird issue I do not understand why keeps happening to me.

All the codes provided in very short form, please ask me if you need any other parts of my code for more information.

My Index view(where user filters results):

@model IEnumerable<Cars.Models.CarSearch>
@using (Html.BeginForm("SearchResult", "Home", FormMethod.Post,
    new
    {
        id = "CategoryFormID",
        data_modelListAction = @Url.Action("ModelList"),
        data_makeListAction = @Url.Action("MakeList"),
        data_editionListAction = @Url.Action("EditionList")
    }))
{
<label>Make</label>
<select id="MakeID" name="carMake">
    <option>All Makes</option>
</select>
}

My SearchResult view:

@model IEnumerable<Cars.Models.Car>

<a href="@Url.Action("SearchResult", "Home", new { sortOrder= "Make", filters = ViewBag.CurrentFilters})">Make</a>

My model:

public class Car
{
    public String Make { get; set; }      //is my table model
}

public class CarFilter {
    public String carMake { get; set; }
}

public class CarSearch {
    public CarFilter CarFilter { get; set; }
    public byte PageSize { get; set; }
    public short PageNumber { get; set; }
    public int TotalRows { get; set; }
}

My Controller:

public ActionResult SearchResult(String sortOrder, CarFilter filters)
    {
        ViewBag.CurrentFilters = filters;

        return View();
    }

All I’m trying to do is to get carMake from Index post it to controller in CarFilter form (since in my code there are LOTS of fields in the form and I don’t want to write them all down) and when user clicks on sort by Make it GET the SearchResult method and it’s supposed to set filters = ViewBag.CurrentFilters which is the value user inputted from beginning.

Now the funny part is, when I replace CarFilter filters with String carMake and other places respectively. It works like a charm.

My question:

  • Why?

  • How can I do this with CarFilter filters?

UPDATE:

Problem is that filters = ViewBag.CurrentFilters in my SearchResult view does not work with the type CarFilter, because it keeps giving me NULL value when user clicked on the sort by Make.

Second UPDATE:

I tried changing filters = ViewBag.CurrentFilters with CarFilter = ViewBag.CurrentFilters. Now CarFilter filters in my SearchResult(...)method in my controller is not and null object, but ALL the values of the objects in the model class is null (which shouldn’t be). I mean the filters object exists but it seems like the values of CarFilter class in my model haven’t been passed by ViewBag.CurrentFilters to the view.

  • 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. Editorial Team
    Editorial Team
    2026-06-16T02:32:42+00:00Added an answer on June 16, 2026 at 2:32 am

    when you canged the name it worked because framework found property name and the bind it to what you have within action parameters doesnt work so nicely with objects. My advice is to stick with simple types

    Here is similiar case:
    How to send model object in Html.RenderAction (MVC3)

    Its not a ViewBag problem thants how it works in general. Its the prime reason for using flatted models :/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have an autohotkey script which looks up a word in a bilingual dictionary
This could be a duplicate question, but I have no idea what search terms
I'm trying to select an H1 element which is the second-child in its group

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.