Introduction: In this
article I will explain how to implement the paging in asp.net listview control
using datapager without using datasource control
Description:
In
the previous article I have explained Add dynamically created controls towebpage and read their values in asp.net and Display gridview selected rowvalues on another page in asp.net.
To
implement this functionality add a webform to project. Drag and drop the
listview and datapager control from toolbox to webform.
HTML
markup of webpage:
<table>
<tr><td>
<asp:ListView ID="ListView1" runat="server"
onpagepropertieschanging="ListView1_PagePropertiesChanging">
<LayoutTemplate>
<table>
<tr>
<th>Student Name</th>
<th>Student
Address</th>
<th>Student Class</th>
</tr>
<tr id="itemPlaceholder" runat="server"></tr>
</LayoutTemplate>
<ItemTemplate>
<tr align="center">
<td> <asp:Label ID="lblstudentname"
runat="server"
Text='<%#Eval("Student_Name")%>'></asp:Label></td>
<td><asp:Label ID="lbladdress" runat="server" Text='<%#Eval("Student_Address") %>'></asp:Label></td>
<td><asp:Label ID="lblroll" runat="server" Text='<%#Eval("RollNo") %>'></asp:Label></td>
</tr>
</ItemTemplate>
</asp:ListView>
</td></tr>
<tr><td></td></tr>
<tr><td><asp:DataPager ID="DataPager1" runat="server" PagedControlID="ListView1" PageSize="3">
<Fields><asp:NextPreviousPagerField ButtonType="Link" ShowFirstPageButton="false" ShowPreviousPageButton="true"
ShowNextPageButton="false"
/>
<asp:NumericPagerField ButtonType="Link" />
<asp:NextPreviousPagerField ButtonType="Link" ShowNextPageButton="true" ShowLastPageButton="false" ShowPreviousPageButton
= "false"
/>
</Fields>
</asp:DataPager></td></tr>
</table>