我正在尝试搜索绑定到转发器控制器的列表中的文本(关键字)。我使用数据列表实现了分页。如果我搜索文本,我会将数据源计为一个,但是如果我检查结果视图“枚举产生没有结果”错误将会出现并且转发器将没有值
这是我的代码
string authorname = AuthorNames();
string ProdTitle = ProductTitle();
string refno = ProductRefno();
List<Product> ProductList = GetProductDetails(categoryName, refno, ProdTitle, authorname);
pageDataSource.DataSource = ProductList;
pageDataSource.AllowPaging = true;
pageDataSource.PageSize = Convert.ToInt16(ddlPageSize.SelectedValue);
pageDataSource.CurrentPageIndex = CurrentPage;
lnkbtnNext.Enabled = !pageDataSource.IsLastPage;
lnkbtnPrevious.Enabled = !pageDataSource.IsFirstPage;
ViewState["totpage"] = pageDataSource.PageCount;
repproductlist.DataSource = pageDataSource;
repproductlist.DataBind();
DoPaging();
// Int32 value = Convert.ToInt32(ConfigurationManager.AppSettings["PaginationDisplayAt"]);
if (ProductList.Count > PaginationDisplayAt)
{
this.paginationDiv.Visible = true;
}
else
{
this.paginationDiv.Visible = false;
}
任何帮助都是有用的
答案 0 :(得分:1)
在绑定之前,您可能需要从搜索结果中创建一个新列表。
repproductlist.DataSource = pageDataSource.FindAll(x => x.Text.Contains(searchString)).ToList();