gridview + custom paging WITHOUT objectdatasource

Discussion in 'ASP .Net Web Controls' started by Kovan A, Jul 14, 2006.

  1. Kovan A

    Kovan A Guest

    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;
    }
     
    Kovan A, Jul 14, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David Hubbard
    Replies:
    0
    Views:
    4,509
    David Hubbard
    Mar 1, 2006
  2. =?Utf-8?B?SmF5IFBvbmR5?=
    Replies:
    2
    Views:
    809
    Steven Cheng[MSFT]
    Nov 14, 2007
  3. Stefan Broenner

    Custom Paging in Gridview/ASP.NET 2.0 without DataSource

    Stefan Broenner, Jul 6, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    261
    Stefan Broenner
    Jul 6, 2005
  4. Dav

    objectdatasource custom paging SelectCount method

    Dav, Jan 10, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    5
    Views:
    291
    Yuan Ren[MSFT]
    Jan 18, 2006
  5. Kovan A

    Gridview + Custom Paging WITHOUT ObjectDataSource

    Kovan A, Jul 10, 2006, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    917
    Teemu Keiski
    Jul 11, 2006
Loading...

Share This Page