在VB.NET中使用DataPager进行ListView控件

时间:2012-05-01 02:26:24

标签: vb.net listview datapager updatepanel

我觉得这很容易。我已经看过很多这方面的帖子,没有一个能够纠正我的情况。我在Update Panel中有一个带有DataPager的ListView控件。第1页显示正常,但后续页面通过寻呼机创建的页码链接为空白。我的ListView通过定义为AsyncPostBackTrigger的按钮进行更新。这是我的ASPX页面:

<body>
<form id="SearchForm" runat="server">
<asp:HiddenField ID="hdnSeasonSelected" Value="" runat="server" />
<asp:HiddenField ID="hdnCategorySelected" runat="server" />
<asp:HiddenField ID="hdnCartNumItems" Value="0" runat="server" />
<div class="Order">
    <div class="OrderCart">
        <uc1:OrderCart ID="OrderCart" runat="server" />
    </div>
    <div class="OrderSearchResults">
        <h2>
            Search Items<hr />
        </h2>
        Brand:
        <asp:DropDownList ID="ddlBrands" runat="server" AppendDataBoundItems="true" onchange="PopulateBrands();">
            <asp:ListItem Text="Select Brand" Value="0"></asp:ListItem>
        </asp:DropDownList>
        Season:
        <asp:DropDownList ID="ddlSeasons" runat="server" onchange="PopulateCategories();">
            <asp:ListItem Text="Select a Brand to View Seasons" Value="0"></asp:ListItem>
        </asp:DropDownList>
        Category:
        <asp:DropDownList ID="ddlCategories" runat="server" onchange="ddlCategories_SelectedIndexChanged()">
            <asp:ListItem Text="Select a Season to View Categories" Value="0"></asp:ListItem>
        </asp:DropDownList>
        <div class="linespace">
        </div>
        <div>
            Item #:
            <asp:TextBox runat="server" ID="txtItemNumber"></asp:TextBox>
            Item Desc:
            <asp:TextBox runat="server" ID="txtItemDesc"></asp:TextBox>
            <asp:Button ID="btnSearch" runat="server" OnClientClick="return CheckSearch();" OnClick="btnSearch_Click"
                Text="Button" />
            <input id="btnReset" type="button" value="Reset" onclick="ResetSearch()" /></div>
    </div>
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:ListView ID="lvSearchResults" runat="server" DataSourceID="SqlDataSource1" GroupItemCount="2">
                <LayoutTemplate>
                    <table>
                        <tr>
                            <td>
                                <table border="1px" style="background-color: #F3F3F3" cellpadding="5">
                                    <asp:PlaceHolder runat="server" ID="groupPlaceHolder"></asp:PlaceHolder>
                                </table>
                            </td>
                        </tr>
                    </table>
                    <asp:DataPager runat="server" ID="DataPager1" PageSize="4" PagedControlID="lvSearchResults">
                        <Fields>
                            <asp:NumericPagerField ButtonCount="3" PreviousPageText="<--" NextPageText="-->" />
                        </Fields>
                    </asp:DataPager>
                </LayoutTemplate>
                <GroupTemplate>
                    <tr>
                    </tr>
                </GroupTemplate>
                <ItemTemplate>
                    <td>
                        <img src="../Images/test.jpg" />
                    </td>
                    <td id="Td5" valign="top" align="left" runat="server">
                        <b>Item #:</b><asp:Label ID="Label4" runat="server" Text='<%#Eval("full_item_number") %>' />
                        <br />
                        <b>Desc:</b>
                        <asp:Label ID="Label5" runat="server" Text='<%#Eval("item_name") %>' />
                        <br />
                        <b>Color:</b>
                        <asp:Label ID="Label7" runat="server" Text='<%#Eval("color_name") %>' />
                        <a href="">Details</a>&nbsp;&nbsp;&nbsp;<a href="">Season / Categories</a>
                    </td>
                    <td id="Td1" valign="top" align="left" runat="server">
                        <b>Price US$:</b>
                        <asp:Label ID="Label6" runat="server" Text='<%#Eval("program_price") %>' />
                        <input id="Button2" type="button" value="Add to Cart" onclick="AddtoCart('<%#Eval("full_item_number") %>','<%#Eval("item_name") %>');" />
                    </td>
                </ItemTemplate>
            </asp:ListView>
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="btnSearch" />
        </Triggers>
    </asp:UpdatePanel>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" CancelSelectOnNullParameter="false">
    </asp:SqlDataSource>
</div>
</form>

有什么想法吗?提前谢谢......鲍勃

1 个答案:

答案 0 :(得分:-1)

修正......只是有一些不好的逻辑!