1

它是我的 aspx 页面的 html

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

在后面的代码中:

protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        dt = objBllinvoice.GetInvoiceStatement(6, 3, "20120404", "20120407");
        lstviewInvoiceReport.DataSource = dt;
        lstviewInvoiceReport.DataBind();
    }
}

我正在将 listview 与 datatable 绑定,它工作正常,但是当我对 listview 进行分页时 a) 我需要双击每个按钮以使其工作。b) listview 中的数据没有根据分页更新。

请在这种情况下帮助我。谢谢

4

2 回答 2

3

当您使用数据分页器时,您必须在 PreRender 中进行数据绑定。您当前正在 Page_Load 中进行数据绑定

于 2012-05-02T19:20:32.200 回答
1

尝试将您的数据绑定到PagePropertiesChangedEvent 中,如下所示:

protected void lstviewInvoiceReport_PagePropertiesChanged(object sender, EventArgs e)
        {
            BindData();
        }
于 2013-08-26T06:56:22.010 回答