我试图过滤基于用户价格范围选择的结果。因此,我选择jquery滑块来显示价格范围。我决定在滑块ajax上使用jquery stop event调用web方法。
在这个阶段,一切都很好,.here是我的web方法的代码,它根据jquery ajax调用传递的min和max范围过滤记录。
[WebMethod]
public static void FilterByPrice(double min,double max)
{
List<BALHotelList> searchresult =(List<BALHotelList>) HttpContext.Current.Session["searchresult"];
searchresult = searchresult.Where(t => (double)t.totalPrice >= min && (double)t.totalPrice <= max).ToList();
HttpContext.Current.Session["searchresult"] = searchresult;
SearchResult s = new SearchResult();
s.Paging();
}现在的问题是用Paging方法来设置中继器控制的datasource。分页方法如下:
protected void Paging()
{
List<BALHotelList> searchresult = (List<BALHotelList>)Session["searchresult"];
PagedDataSource objPds = new PagedDataSource();
objPds.DataSource = searchresult;
objPds.AllowPaging = true;
objPds.PageSize = Convert.ToInt32(ddlPageNo.SelectedValue);
objPds.CurrentPageIndex = CurrentPage;
lblCurrentPage.Text = "Page: " + (CurrentPage + 1).ToString() + " of "
+ objPds.PageCount.ToString();
// Disable Prev or Next buttons if necessary
cmdPrev.Enabled = !objPds.IsFirstPage;
cmdNext.Enabled = !objPds.IsLastPage;
rptHotels.DataSource = objPds;
rptHotels.DataBind();
}当调用此方法时,对象引用未设置的通过错误。据我所知,此时间页面控件无法访问。当我读到一些完全否定这个有关访问页控制的问题的答案时
现在我想知道我应该用什么方法来完成我的任务
使用jquery价格滑块过滤记录?
发布于 2012-07-30 02:35:24
一种选择是更改WebMehtod签名以返回筛选的记录,它们使用jQuery来显示它们。这可以通过DataTables jQuery插件来实现,这是一个用于构建功能丰富的html表的开源工具。
这个javascript示例代码展示了如何使用jQuery设置和填充DataTable。
https://stackoverflow.com/questions/11712881
复制相似问题