K
Kovan A
I am trying to implement my own custom paging (bringing back a virtual count
of 10000+ and only 20 records or so of real records)
however the gridview is not behaving properly and only takes 20 records into
considaration when it does totalPage count instead of the virtualcount i
specified
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
bindCustomers(0);
}
}
private void bindCustomers(int indexPage)
{
CustomerCollection custs = new CustomerCollection();
IPredicateExpression pred = new PredicateExpression();
pred.Add(PredicateFactory.CompareValue(CustomerFieldIndex.MarketID,
ComparisonOperator.Equal, 9));
int total = custs.GetDbCount(pred); //GET THE TOTAL RECORDS FOR
VIRTUAL PAGING
custs.GetMulti(pred, 0, null, null, indexPage + 1, 20); //ONLY GET
THE 20 RECORDS
PagedDataSource ds = new PagedDataSource();
ds.VirtualCount = total;
ds.AllowCustomPaging = true;
ds.CurrentPageIndex = indexPage;
ds.DataSource = custs;
gvCustomers.DataSource = ds;
gvCustomers.DataBind();
}
protected void gvCustomers_PageIndexChanging(object sender,
GridViewPageEventArgs e)
{
bindCustomers(e.NewPageIndex);
gvCustomers.PageIndex = e.NewPageIndex;
}
of 10000+ and only 20 records or so of real records)
however the gridview is not behaving properly and only takes 20 records into
considaration when it does totalPage count instead of the virtualcount i
specified
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
bindCustomers(0);
}
}
private void bindCustomers(int indexPage)
{
CustomerCollection custs = new CustomerCollection();
IPredicateExpression pred = new PredicateExpression();
pred.Add(PredicateFactory.CompareValue(CustomerFieldIndex.MarketID,
ComparisonOperator.Equal, 9));
int total = custs.GetDbCount(pred); //GET THE TOTAL RECORDS FOR
VIRTUAL PAGING
custs.GetMulti(pred, 0, null, null, indexPage + 1, 20); //ONLY GET
THE 20 RECORDS
PagedDataSource ds = new PagedDataSource();
ds.VirtualCount = total;
ds.AllowCustomPaging = true;
ds.CurrentPageIndex = indexPage;
ds.DataSource = custs;
gvCustomers.DataSource = ds;
gvCustomers.DataBind();
}
protected void gvCustomers_PageIndexChanging(object sender,
GridViewPageEventArgs e)
{
bindCustomers(e.NewPageIndex);
gvCustomers.PageIndex = e.NewPageIndex;
}