Skip to content

Instantly share code, notes, and snippets.

@RyanABailey
Created March 20, 2014 04:24
Show Gist options
  • Save RyanABailey/9657239 to your computer and use it in GitHub Desktop.
Save RyanABailey/9657239 to your computer and use it in GitHub Desktop.
ListView Paging
<asp:DataPager ID="DataPager1" runat="server" PagedControlID="ListView1" PageSize="10">
<Fields>
<asp:NumericPagerField ButtonType="Link" />
</Fields>
</asp:DataPager>
protected void ListView1_PagePropertiesChanging(object sender, PagePropertiesChangingEventArgs e)
{
//set current page startindex, max rows and rebind to false
lvDataPager1.SetPageProperties(e.StartRowIndex, e.MaximumRows, false);
// bind data to list view
BindData();
}
<asp:ListView ID="ListView1" runat="server" OnPagePropertiesChanging="ListView1_PagePropertiesChanging">
<LayoutTemplate>
<ul>
<asp:PlaceHolder ID="itemPlaceholder" runat="server" />
</ul>
</LayoutTemplate>
<ItemTemplate>
<li>
<%# Eval("DataField") %>
</li>
</ItemTemplate>
<EmptyDataTemplate>
No data to display
</EmptyDataTemplate>
</asp:ListView>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment