2

relating (or lets say due to) to the following topic i am able to handle the scrolling-event in my ListView: How to make scroll event for ListView

In my case i will need this to display about 60k rows on a single page without using pagination to reduce performance impacts.

My question now is: What would be the best way to handle this / to load my data dynamically once the scroll event triggers...?

At the moment i am loading about 100 rows on programm-start and add one row on each scroll-trigger. In the background i am using a simple LIMIT-SQL stagement.

To be honest this doesn't look very well (you actual can see something is beeing loaded so it's not smooth) and sometimes it seems to cause some access validation errors.

So what would be the generel idea to do such things? I might need some shove in the right direction :-)

Thanks for your assistance.

Best regards Teyhouse

Community
  • 1
  • 1
Teyhouse
  • 61
  • 1
  • 5

2 Answers2

1

i did some thing of these a few months back. So the trick was always to load N-number of rows not 1 row as it would be very inefficient(just like what FB and google reader does) when scroll is just about to end. So in your case always load 100 rows, when your scroll is about to end.

Here is link of 1 article that I followed

An advice - Instead of mixing asp.net list view with JQuery ajax, it would be nice if you build your listview(i.e table) entirely in JS and then load data using AJAX.

Anand
  • 14,545
  • 8
  • 32
  • 44
  • Thanks for your reply, i will do it this way but i am not using ASP.NET it is a simple Form-Application i should have told that before, sorry... I made some mistake in my way to handle the data i loaded new rows on each scroll-down in the listview... it seems to be a better idea to load the data once the end of the listview is reached... – Teyhouse Aug 20 '13 at 15:45
0

Solution of this problem is easy. Take a look only on that section (listView1.Height-26)/17; - listview.Height - 26 // 26 its a column heigh, 17 - this is the row heigh i listView. Of course you can calculate this param using your own code.

private const int SB_VERT = 1;
public void ScrollList() {
    int items_on_page = (listView1.Height-26)/17;
    ScrollEventArgs sarg = new ScrollEventArgs(ScrollEventType.EndScroll, GetScrollPos(this.Handle, SB_VERT));
    items_count = listView1.Items.Count;
    int scroll_pos = listView1.ScrollPosition;
    int left_pos = items_count-scroll_pos;

    if(left_pos<=items_on_page+2) {
        // load more data into the listview
    }
}
protected override void WndProc(ref Message m)   {
    base.WndProc(ref m);
    switch(m.Msg)
    {
        case WM_VSCROLL:
            ScrollList();
        break;
        case WM_MOUSEWHEEL:
            ScrollList();
        break;
     }
}
user2536592
  • 171
  • 1
  • 6