gridview + custom paging WITHOUT objectdatasource

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;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top