使用html表在mvc3中进行分页

时间:2014-02-18 10:35:44

标签: c# html asp.net-mvc-3

[HttpGet]
public ActionResult SearchByOperator(DateTime fromdate, DateTime todate, string operatorname,int page=1)
{
   List<CRBT_CALLS> operator_list = new List<CRBT_CALLS>();
   using (crbt_onwebEntities dbcontext = new crbt_onwebEntities())

   operator_list = (from z in dbcontext.CRBT_CALLS
                    where z.DOWNLOAD_TIME > fromdate && z.DOWNLOAD_TIME < todate && z.OPERATOR == operatorname
                    select z).OrderBy(x => x.DOWNLOAD_TIME).ToList();

这是我的浏览页面。当我点击1,2,3和分页链接时,它显示:

The parameters dictionary contains a null entry for parameter 'fromdate' of non-nullable type 'System.DateTime' for method 'System.Web.Mvc.ActionResult SearchByOperator(System.DateTime, System.DateTime, System.String, Int32)' in 'mvclogin.Controllers.HomeController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
Parameter name: parameters

1 个答案:

答案 0 :(得分:1)

根据错误页面,您似乎没有在分页链接中包含适当的参数。错误消息表明未包含fromDate参数,并且由于这是必需参数,并且没有其他操作与您的路由匹配,因此会引发错误。

您应该在分页链接的查询字符串中包含所有参数信息(fromdate,todate等),或者重新定义Action以允许这些参数是可选的。

相关问题