Virtual Listview for ASP.net?

前端 未结 2 573
抹茶落季
抹茶落季 2021-01-15 04:18

Is there a virtual listview for ASP.net?


Most tables (and grids, listview, data tables, data grids, grid views, list grids) i find for asp.net expect the user

2条回答
  •  一生所求
    2021-01-15 05:08

    I just make one virtual ListView sample.

    I start with a repeater that I render divs, with an attribute that contain the Data Base id that need to be loaded.

    
    
            
    loading...

    Next the javascript that check if this div is visible, and get the data using ajax.

    
    
    
    

    and here is my code behind as test that one

    public partial class Dokimes_StackOverFlow_VirtualList : System.Web.UI.Page
    {
        List oMainIds = new List();
    
        protected void Page_Load(object sender, EventArgs e)
        {
            for (int i = 0; i < 3000; i++)            
                oMainIds.Add(i);            
    
            Repeater1.DataSource = oMainIds;
            Repeater1.DataBind();
        }
    
        public int GetID(object oItem){
            return (int)oItem;
        }
    }
    

    I tested and its working just find.

    and here is the source code: http://www.planethost.gr/VirtualList.rar

    Improvements that can be done:

    • To optimize what div to search for visibility base on the scroll point.
    • To load a group of data and place them on divs

    Update I make some speed optimizing, and add ajax call test. For this optimizations work correct the height of the div that contains the data must be the same across the page. Left to load a group of data, get them as json and place them on the correct place.

    http://www.planethost.gr/VirtualList2.rar

提交回复
热议问题