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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:56:51+00:00 2026-05-25T02:56:51+00:00

I am using MvcContrib Grid control in my MVC application. Following the example in

  • 0

I am using MvcContrib Grid control in my MVC application. Following the example in the Pro*ASP.NET MVC book I have the following class and paging helper created

public class PagingInfo

{
    public int TotalItems { get; set; }
    public int ItemsPerPage { get; set; }
    public int CurrentPage { get; set; }
    public int TotalPages
    {
        get { return (int)Math.Ceiling((decimal)TotalItems / ItemsPerPage); }
    }

public static class PagingHelpers
{
    public static MvcHtmlString PageLinks(this HtmlHelper html,
                                          PagingInfo pagingInfo,
                                          Func<int, string> pageUrl)
    {

        StringBuilder result = new StringBuilder();
        for (int i = 1; i <= pagingInfo.TotalPages; i++)
        {
            TagBuilder tag = new TagBuilder("a"); // Construct an <a> tag

            tag.MergeAttribute("href", pageUrl(i));

            tag.InnerHtml = i.ToString();

            if (i == pagingInfo.CurrentPage)
                tag.AddCssClass("selected");
            result.AppendLine(tag.ToString());
        }
        return MvcHtmlString.Create(result.ToString());
    }
}

In my View, I have the following:

Page: @Html.PageLinks( ViewBag.Paging as PagingInfo, i => Url.Action(“Index”, new{pageNo = i}))

 @Html.DropDownList("pageSize", new SelectList(new[] { "2", "25", "50", "75", "100", "200" }), "-Select-", new { @style = "width:75px" })   

1)
How do I send in the pageSize (which is the number of rows) to the helper class using the Url.Action?

2)
I have also defined the following function to enable ajax. Is this an efficient way to go about it? I was going to use a similar function for the soring too. So your views would be appreciated.

$(“#pageLinks a”).live(“click”, function() {

    $.get($(this).attr("href"), function(response) {
        $("#Grid").replaceWith(response); 
    });

    return false;


});

Thanks,

  • 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-05-25T02:56:51+00:00Added an answer on May 25, 2026 at 2:56 am

    In case anybody else is having the same issue, with sending in additional parameters. I changed my html helper function as follows:-

    public static MvcHtmlString PageLinks(this HtmlHelper html,
                                                  PagingInfo pagingInfo,
                                                  Func<int, int, string> pageUrl)
            {
    
                StringBuilder result = new StringBuilder();
                for (int i = 1; i <= pagingInfo.TotalPages; i++)
                {
                    TagBuilder tag = new TagBuilder("a"); // Construct an <a> tag
    
                    tag.MergeAttribute("href", pageUrl(i, pagingInfo.ItemsPerPage));
    
                    tag.InnerHtml = i.ToString();
    
                    if (i == pagingInfo.CurrentPage)
                        tag.AddCssClass("selected");
                    result.AppendLine(tag.ToString());
                }
                return MvcHtmlString.Create(result.ToString());
            }
    

    And I now call the function as follows:

    Page: @Html.PageLinks( ViewBag.Paging as PagingInfo, (i, j) => Url.Action("Index", new{pageNo = i, pageSize= j}))  
    
    It works a treat now.  Must RTFM more.  Thanks to the Plural Sight videos for helping me resolve this one. 
    

    Thanks,

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

Sidebar

Related Questions

I am using mvccontrib grid in asp.net mvc(C#) application. How can i apply css
I'm working in ASP.NET MVC 1.0 using MvcContrib FluentHtml version 1.0. The following code
I am using a ASP.NET MVC 3 Mvccontrib grid like so: @Html.Grid(Model).Columns(column => {
I'm trying to implement a paging and sorting list in ASP.NET MVC without using
I have been following this nice walkthrough for creating a grid using MVC contrib.
If you are using ASP.NET MVC how are you doing grid display? Rolled your
I have the following partial view code @model IEnumerable<PDoc.Web.Models.UserDocModel> @using MvcContrib.UI.Grid; @using MvcContrib.UI.Pager; @using
This is ASP.NET MVC v1 (not using the v2 yet) I have a route
I inherited an ASP.NET MVC 1 website using MVCContrib 1.5 that I'm trying to
I have a big .net mvc 2 project where we are using MvcContrib Portable

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.