Muhammed Afzaal

Muhammed Afzaal

  • NA
  • 127
  • 2.3k

WebGrid Bind Error in Asp.net MVC

Feb 9 2018 2:59 PM
Hello,

I am very much new to the asp.net mvc. I am trying to work on webgrid server side paging but i am facing an error while binding the webgrid. I am attaching the error snap. Following are the codes:

Controller:
public ActionResult WebGrid(int page=1,string sort = "", string sortdir = "", string search = "")
{
var list = new List<Product>();
int DisplayLength = 10;
int DisplayStart = (page * DisplayLength) - DisplayLength;
list = pad.GetPrdListInChunks_1(DisplayLength, DisplayStart, sort, sortdir);
ViewBag.TotalRows = list[0].TotalCount;
ViewBag.Search = search;
return View(list);
}
 
View:
@model List<NorthwindApplication.Models.Product>
@{
Layout = "~/Views/Shared/_Layout.cshtml";
WebGrid grid = new WebGrid(canPage: true, rowsPerPage: 10);
grid.Bind(Model, rowCount: ViewBag.TotalRows, autoSortAndPage: false);
}
 
Error:


The best overloaded method match for 'System.Web.Helpers.WebGrid.Bind(System.Collections.Generic.IEnumerable<object>, System.Collections.Generic.IEnumerable<string>, bool, int)' has some invalid arguments

 
 
 
 
 

Answers (1)