ASP.Net Listview & AJAX Update Panel

我的未来我决定 提交于 2019-12-24 20:34:23

问题


I have to create a listview which contains thumbnails of few items, and when we click on the more button it should display rest of the items in the same listview,. how do i achive this, i dont want to do a postback and i would like to do this with ASP.Net Listview and AJAX Update Panel,

i went through the web and seems ppl are finding difficulties in this, do you have any suggestions or tips in doing this, any help is much appreciated.


回答1:


Should be fairly simple.

Use a Take() for your initial small sample databind and don't for the full one.

Something like:

class Blah
 {
     private const sampleNumber = 10;


   overrides OnLoad(...)
   {
    this.DataBind();
   }

   protected MoreButtonHandler(...)
   {
      this.DataBind(false);
   }


   overrides protected DataBind()
   {
    this.DataBind(true);
   }

   (shadows?) overrides protected  DataBind(bool sampleOnly)
   {

     var thumbnails = this.loadThumbnails();
     if(sampleOnly)
      thumbnails = thumbnails.Take(Blah.sampleNumber);

     this.listview.datasource = thumbnails ;
     mybase.DataBind();

   }

   private IEnumerable<Thumbnail> loadThumbnails()
   {
     etc...
   }
}


来源:https://stackoverflow.com/questions/1782873/asp-net-listview-ajax-update-panel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!