Reputation: 317
its the html of my aspx page
<asp:ListView ID="lstviewInvoiceReport" runat="server">
<LayoutTemplate>
<table style="font-size: medium; font-family: Times New Roman">
<tr>
<th>
Date
</th>
<th>
Biller
</th>
<th>
Customer
</th>
<th>
Total
</th>
<th>
Owing
</th>
<th>
Paid
</th>
</tr>
<tr>
</tr>
<asp:PlaceHolder runat="server" ID="itemPlaceholder"></asp:PlaceHolder>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td>
<asp:Label runat="server" ID="lblDate"><%#Eval("InvoiceDate") %></asp:Label>
</td>
<td>
<asp:Label runat="server" ID="lblBillerName"><%#Eval("BillerName") %></asp:Label>
</td>
<td>
<asp:Label runat="server" ID="lblCustName"><%#Eval("CustName") %></asp:Label>
</td>
<td>
<asp:Label runat="server" ID="lblTotal"><%#Eval("InvoiceTotal") %></asp:Label>
</td>
<td>
<asp:Label runat="server" ID="lblOwing"><%#Eval("InvoiceOwing") %></asp:Label>
</td>
</tr>
</ItemTemplate>
</asp:ListView>
<br />
<asp:DataPager ID="DataPager1" runat="server" PagedControlID="lstviewInvoiceReport"
PageSize="2">
<Fields>
<asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowNextPageButton="False"
ShowPreviousPageButton="False" />
<asp:NumericPagerField />
<asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True" ShowNextPageButton="False"
ShowPreviousPageButton="False" />
</Fields>
</asp:DataPager>
and in code behind :
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
dt = objBllinvoice.GetInvoiceStatement(6, 3, "20120404", "20120407");
lstviewInvoiceReport.DataSource = dt;
lstviewInvoiceReport.DataBind();
}
}
I am binding listview with datatable its working fine but when I'm paginating listview a) I need to click double each button to make it work. b) data inside listview is not updating according to pagination.
Please help me in this situation. Thanks
Upvotes: 1
Views: 2357
Reputation: 1362
Try to put bind your data in PagePropertiesChanged
Event like this:
protected void lstviewInvoiceReport_PagePropertiesChanged(object sender, EventArgs e)
{
BindData();
}
Upvotes: 1
Reputation: 788
When you use a datapager you have to data bind in PreRender. You're currently databinding in Page_Load
Upvotes: 3