Asp.net DataPager无法与Listview一起正常工作
这是我的aspx页面的htmlAsp.net DataPager无法与Listview一起正常工作,asp.net,listview,datapager,Asp.net,Listview,Datapager,这是我的aspx页面的html <asp:ListView ID="lstviewInvoiceReport" runat="server"> <LayoutTemplate> <table style="font-size: medium; font-family: Times New Roman"> <tr> <th>
<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>
我正在将listview与datatable绑定,工作正常,但在对listview进行分页时
a) 我需要双击每个按钮使其工作。
b) listview中的数据未根据分页进行更新
在这种情况下请帮助我。谢谢当您使用datapager时,您必须在PreRender中绑定数据。当您使用datapager时,您当前正在Page_Load中进行数据绑定,您必须在PreRender中进行数据绑定。您当前正在Page_Load中进行数据绑定尝试将数据绑定到
PagePropertiesChanged
事件中,如下所示:
protected void lstviewInvoiceReport_PagePropertiesChanged(object sender, EventArgs e)
{
BindData();
}
尝试将数据绑定到
PagePropertiesChanged
事件中,如下所示:
protected void lstviewInvoiceReport_PagePropertiesChanged(object sender, EventArgs e)
{
BindData();
}
好的,谢谢raynjamin,请更新我的声誉,以便我可以发布更多答案。嗨,raynjamin,请提高您对这个问题的投票谢谢:)好的,谢谢raynjamin,请更新我的声誉,以便我可以发布更多答案。嗨,raynjamin,请提高您对这个问题的投票谢谢:)