Why aren't MVC3 webgrid paging and sorting working?

I'm using MVC3 webgrid to display, sort and paginate data. The display is fine, but when I click on a new page or request a sort, nothing is happening.

This is the code that I'm using:

@if (Model.AdsList != null) { WebGrid adGrid = new WebGrid(Model.AdsList, rowsPerPage: 10, canSort: true, ajaxUpdateContainerId: "adsGrid"); <div> @adGrid.Pager(WebGridPagerModes.NextPrevious); @adGrid.GetHtml(tableStyle: "webGrid", headerStyle: "header", alternatingRowStyle: "alt", htmlAttributes: new { id = "adsGrid", width = "100%" }, columns: adGrid.Columns( //columns )); </div> }

The data is loading correctly, but none of the links generated are working. Is there anything I need to do in controller for paging and sorting?

EDIT : I am getting this page as a result of post operation from another page .There is not GET action with same name in the controller.

code is shown below in controller

[HttpPost] public ActionResult Search(SearchModel model) { //some operation return view(model); }

I also like to know how paging is working . Is the webgrid query against data base every time when i click next page or sort links?

-------------Problems Reply------------

var grid = new WebGrid(source: Model, rowsPerPage: 6,canPage: true, canSort: true, );

@grid.GetHtml(headerStyle: "gridtableheader", footerStyle: "paging",
columns:
grid.Columns(
//Columns
),
mode: WebGridPagerModes.All)

// different modes of paging

mode: WebGridPagerModes.FirstLast
mode: WebGridPagerModes.NextPrevious
mode: WebGridPagerModes.Numeric

Hope This will solve your problem

Category:asp.net mvc Views:1 Time:2011-11-04

Related post

  • MVC3 Webgrid Paging and Sorting 2011-07-18

    I'm using MVC3 webgrid to display, sort and paginate data. The display is fine, but when I click on a new page or request a sort, it opens the table in a brand new window on it's own? Anybody know why this happens? It is contained within a partial vi

  • MVC3 WebGrid disappears after sorting or paging with a filter 2012-04-20

    I am having the same issue as this question. I have created a filter that is supposed to work alongside a WebGrid. The filter works for the first page, but if you try to go to a different page or sort the results, the filter is lost. I followed the s

  • Asp Mvc3 webgrid Paging and Filtering by ajax 2012-01-20

    I Have a little problem with WebGrid control for Asp.Net MVC3. What I want is to perform a search view using ajax and webgrid; something like this: Search Criteria ______________________________ Subject: _____ Task Type: _____ SUBMIT SEARCH WebGrid w

  • MVC3 Webgrid Paging is not working inside a Jquery dialog 2012-01-30

    I have a Jquery dialog and I load a view to it which contains a webgrid. It opens normally and display content in a webgrid. But when I click a paging link, then next page of webgrid is not open within the dialog but as a different page in the browse

  • Asp.net Mvc3 webgrid and paging 2011-06-14

    I am trying to learn Asp.net mvc. I know its different from forms and i need to change my way of thinking probably. My problem is about webgrid . When i add webgrid to my page and hit search button with Post it renders table with pager and so on. But

  • webgrid ajax paging and sorting, asp.net mvc3 razor 2012-03-12

    I am using a Webgrid in my project to display data, and have it working fine with paging and sorting. I have included a hyperlink column for "Slmgreferencenumber" like this: grid.Column("SlmgReferenceNumber", header: "SLMG Number", format: @<text

  • Razor webgrid ajax paging and sorting 2010-12-03

    I'm trying to learn how to use Razor WebGrid in MVC3. How does the ajaxUpdateCallback parameter work? --------------Solutions------------- The ajaxUpdateCallback is the name of the javascript function that will get called after the server call is com

  • MVC3 WebGrid toggling sort direction 2011-11-12

    With an ASP.NET MVC3 WebGrid how can I setup the column sorting such that clicking on the column heading toggles between ascending sort and then descending sort? Thanks! Rob --------------Solutions------------- The underlying problem turned out to be

  • ASP.NET MVC3 WebGrid - custom, server-side sorting 2012-04-12

    Is there a way to override default MVC3 WebGrid sorting behavior to call my controller (which will perform server side sorting and return the data) when sort is called? Thanks for any help! --------------Solutions------------- You can pass the server

  • Server side paging for MVC3 Webgrid 2011-06-21

    I have looked at a number of examples (e.g. http://www.dotnetcurry.com/ShowArticle.aspx?ID=618 and http://msdn.microsoft.com/en-us/magazine/gg650669.aspx) but it seems very manual and convoluted. The reason I would like to use the WebGrid is that the

  • MVC3 paging and sorting without grid? 2011-07-26

    I was wondering if it's possible to implement paging and sorting of data using a @foreach Razor syntax instead of using a specific Grid control. Would it be difficult to implement? Should I stick to existing Grid solutions instead, such as WebGrid or

  • Telerik Grid paging and Sorting in ASP.Net MVC3(aspx engine) 2012-02-12

    I am using Telerik Rad Grid in MVC3(aspx engine) like:- This is my Controller:- [HttpGet] [GridAction(EnableCustomBinding = true)] public ActionResult Search() { SearchViewModel searchViewModel = new SearchViewModel(this.serviceInvoker); SearchReques

  • MVC3 WebGrid is holding onto it's paged data after a new grid is created via post! 2011-06-14

    I'm having an issue with WebGrid paging; but first, here's some controller pseudo code: public ActionResult Date() { var data = getLINQ(); return View(data); } [HttpPost] public ActionResult Date(string start, string finish) { var data - getLINQ(star

  • Updating div outside ajaxUpdateContainerId when using MVC3 WebGrid 2011-03-30

    Using ASP.NET MVC3 I have a page with this bit: <div id="grid"> <div>@[email protected] of @ViewBag.TotalHits hits</div> <div style="clear: both;"></div> @{ @grid.GetHtml( mode: WebGridPagerModes.All, disp

  • ASP.NET MVC 3 - WebGrid paging problems and general confusion 2011-08-15

    I am relatively new at using ASP.NET MVC, however I have got experience with using Web Forms. My page has some cascading selects which in turn ajax load the next and finally reload the contents of the ajax tabs (jQuery UI). One of the tabs has a sear

  • paging and sorting using jquery 2009-09-01

    I want to use paging and sorting using jquery.I want to embed this with jsp/servlets at back end. --------------Solutions------------- Ingrid, the jQuery Datagrid. is a nice jQuery grid with paging and sorting options. Some more options Flexigrid jQG

  • GridView sorting doesn't work when I Enable Caching in Custome Paging and sorting 2009-12-29

    I have a GridView that use a stored procedure for custom paging and sorting . It's OK and works fine (Both paging and sorting) , But the problem is when i Enable Caching in ObjectDataSource like : EnableCaching="True" It properly cache every page tha

  • Storing search result for paging and sorting 2010-02-15

    I've been implementing MS Search Server 2010 and so far its really good. Im doing the search queries via their web service, but due to the inconsistent results, im thinking about caching the result instead. The site is a small intranet (500 employees

  • Gridview paging and sorting do not work after changing datasource in codebehind? 2010-03-05

    I am having a gridview with an object datasource binded in the markup(aspx page). When page loads it directly works fine with all sorting and paging properties. However, i need to filter display on gridview so i have to change the datasource of the g

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.098 (s). 11 q(s)