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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:30:25+00:00 2026-06-12T22:30:25+00:00

Lets say I render a Checkbox: @Html.CheckboxFor(x => x.Checked) // Checked is true by

  • 0

Lets say I render a Checkbox:

@Html.CheckboxFor(x => x.Checked) // Checked is true by default

ASP will turn that as:

<input checked="checked" data-val="true" data-val-required="The field is required." id="Checked" name="Checked" type="checkbox" value="true" />
<input name="Checked" type="hidden" value="false" />

Since ASP outputs two inputs with the same name for a Checkbox, we also get two GET parameters in the URL when submitting the form with the checkbox:

http://...?Checked=true&Checked=false

Lets say I’m also using MvcContrib for displaying a table with sorting.

When I sort a column, MvcContrib is unable to understand the duplicate GET parameters, and instead of writing ?Checked=true&Checked=false, it writes ?Checked=true%2Cfalse, which can’t be parsed to a bool by MVC3. The error message after sorting is:

String was not recognized as a valid Boolean.

Has anyone else experienced this problem with the MvcContrib grid?

  • 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-12T22:30:26+00:00Added an answer on June 12, 2026 at 10:30 pm

    Okay, think I have come up with the solution:

    Create your own HtmlTableGridRenderer:

    public class CustomTableGridRenderer<TViewModel> : HtmlTableGridRenderer<TViewModel> where TViewModel : class
    {
        protected override void RenderHeaderText(GridColumn<TViewModel> column)
        {
            if (IsSortingEnabled && column.Sortable)
            {
                string sortColumnName = GenerateSortColumnName(column);
    
                bool isSortedByThisColumn = GridModel.SortOptions.Column == sortColumnName;
    
                var sortOptions = new GridSortOptions
                {
                    Column = sortColumnName
                };
    
                if (isSortedByThisColumn)
                {
                    sortOptions.Direction = (GridModel.SortOptions.Direction == SortDirection.Ascending)
                        ? SortDirection.Descending
                        : SortDirection.Ascending;
                }
                else //default sort order
                {
                    sortOptions.Direction = column.InitialDirection ?? GridModel.SortOptions.Direction;
                }
    
                var routeValues = CreateRouteValuesForSortOptions(sortOptions, GridModel.SortPrefix);
    
                //Re-add existing querystring
                foreach (var key in Context.RequestContext.HttpContext.Request.QueryString.AllKeys.Where(key => key != null))
                {
                    if (!routeValues.ContainsKey(key))
                    {
                        routeValues[key] = Context.RequestContext.HttpContext.Request.QueryString[key];
                    }
                }
    
                var link = HtmlHelper.GenerateLink(Context.RequestContext, RouteTable.Routes, column.DisplayName, null, null, null, routeValues, null);
                RenderText(link);
            }
            else
            {
                base.RenderHeaderText(column);
            }
        }
    }
    

    … and just replace

                    if(! routeValues.ContainsKey(key))
                    {
                        routeValues[key] = Context.RequestContext.HttpContext.Request.QueryString[key];
                    }
    

    … with routeValues[key] = Context.RequestContext.HttpContext.Request.QueryString[key];

    And use your new rendering like so:

    @Html.Grid()…RenderUsing(new CustomTableGridRenderer())

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

Sidebar

Related Questions

Let's just say that I need to render a certain amount of HTML over
Lets say I wish to be able to render different view logic for two
Lets say we have a table here, populated with the following data: acc_id1 acc_id2
Lets say I have a class A that is fairly simple like this -
Lets take a static html page as a scenario, lets say you have a
Lets say I have a function in my model, that generates a style tag
Lets say I render the character A to the screen with a size 14
Lets say I have an image that has a DPI of 72 and a
Lets say I wanted to scrape a webpage, and extract some data. I'd most
Lets say I have five tables named table1, table2 ... table5. I have already

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.