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

  • SEARCH
  • Home
  • 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 8431333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:49:36+00:00 2026-06-10T05:49:36+00:00

I have a webgrid with sorting and paging enabled. I also have some dropdownlists

  • 0

I have a webgrid with sorting and paging enabled. I also have some dropdownlists and listboxes on the same view to filter the webgrid result.

The filters are placed inside a form with http get method. I applied jquery on the filters to submit the form so every time when the filter changes, the form posts back with the selected value as querystring in the url. When multiple values are selected in listbox, the querystring generated looks like

type=1&type=3

So I created a int[] type to accept the parameters in my action. However when I sort or page the webgrid, the querystring is rewritten to

type=1,3&page=4,

in which case the type argument becomes null, the listbox is unselected and amended with a “input-validation-error” class automatically.

I actually prefer the style of the querystring generated by webgrid

type=1,3

so I can pass it directly into my query. However, it seems the listbox doesn’t like this kind of the querystring. Is there a way to make the listbox to recognise the combined querystring or I have to write code to handle the querystring and selected items?

  • 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-10T05:49:38+00:00Added an answer on June 10, 2026 at 5:49 am

    Thanks. I ended up by doing the similar job in a customized model binder

    class MultiSelectionBinder : IModelBinder
    {
        public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            string key = bindingContext.ModelName;
            ValueProviderResult val = bindingContext.ValueProvider.GetValue(key);
            if (val != null && !string.IsNullOrEmpty(val.AttemptedValue))
            {
                bindingContext.ModelState.SetModelValue(key, val);
    
                string incomingString = ((string[])val.RawValue)[0];
                if (incomingString.Contains(","))
                {
                    var value = new ValueProviderResult(incomingString.Split(','), string.Empty, CultureInfo.InvariantCulture);
                    bindingContext.ModelState.SetModelValue(key, value);
                    return value.ConvertTo(typeof(int[]));
                }
    
                return val.ConvertTo(typeof(int[]));
            }
    
            return null;
        }
    }
    

    And applied it to the arguments

    public ViewResult Index([ModelBinder(typeof(MultiSelectionBinder))] int[] type, ...)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I Have used WebGrid to take benefit of inbuilt sorting and paging in MVC
Have deployed numerous report parts which reference the same view however one of them
When you enable paging and sorting on MVC's WebGrid, it automatically appends sort and
I have some short questions about the Webgrid. How can I put in a
I'm having an issue with WebGrid paging; but first, here's some controller pseudo code:
I'm new to MVC so have some conceptual issues. I have a WebGrid that
I have an mvc3 webgrid that contains results that I would like to filter
I have assigned data to the webgrid but it sorting the columns alphabetically. it
I have a simple webgrid which displays list. I also have a combobox which
I am using a webgrid to display some dynamic data. I have recently refactored

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.