问题
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