Aneef
Aneef

Reputation: 3729

ASP.Net Listview & AJAX Update Panel

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.

Upvotes: 0

Views: 1527

Answers (1)

Mark Holland
Mark Holland

Reputation: 846

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

Upvotes: 1

Related Questions