0

データベースにリンクされた検索ページを作成しました。ページが読み込まれると、VB Codebehind を使用してSqlSelectCommandforを設定し、ListView結果が 0 になるようにします。クライアントがアイテムを検索すると、Sql select を に変更しますLIKE '%search%'

これはすべて正常に機能しますが、2ページ目をクリックすると元のSQLステートメントに戻ります

Labelデータがページに返されることを確認するために、検索キーに従って動的に変更する見出しにも使用しています

ここで私のサイトをプレビューできます http://www.barkingdog.co.za/asp/Search1.aspx

Officeページでも同じ問題が発生しますが、SQL選択でデータを使用してページを開始しますが、たとえばクリックすると. エコノミーを選択してからページ 2 に移動しようとすると、元のコンテンツのページ 2 が表示されます

前もって感謝します

VB

Protected Sub SearchBox_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles SearchBox.TextChanged
    Dim nval As String
    nval = Searchbox.Text
    BreadCrumb.Text = "Results for " + nval

    AllProductsOff.SelectCommand = "SELECT * FROM [cxpproducts] WHERE [Range]  LIKE '%" & nval & "%'"
End Sub

Protected Sub SearchButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SearchButton.Click
    Dim nval As String
    nval = Searchbox.Text
    BreadCrumb.Text = "Results for " + nval

    AllProductsOff.SelectCommand = "SELECT * FROM [cxpproducts] WHERE [Range]  LIKE '%" & nval & "%'"
End Sub

ASP

  <asp:TextBox ID="SearchBox" runat="server" 
    AutoPostBack="True"></asp:TextBox>

  <asp:Button ID="SearchButton" runat="server" 
    Text="Search" PostBackUrl="./Search1.aspx" style="margin-top: 0px" />

リストビュー

 <LayoutTemplate>
   <div style="" align="center">
     <asp:DataPager ID="DataPager2" runat="server">
       <Fields>
         <asp:NextPreviousPagerField ButtonType="Link" ShowFirstPageButton="True" 
                        ShowNextPageButton="True" ShowPreviousPageButton="True" NextPageText=">>" LastPageText="Last" PreviousPageText="<<" />
         <asp:NumericPagerField />
         <asp:NextPreviousPagerField ButtonType="Link" ShowLastPageButton="True" 
                        ShowNextPageButton="False" ShowPreviousPageButton="False" />
       </Fields>
     </asp:DataPager>
   </div>
   <div ID="itemPlaceholderContainer" runat="server" class="style25">
     <span runat="server" id="itemPlaceholder" />
   </div>
   <div style="" align="center">
     <asp:DataPager ID="DataPager1" runat="server">
       <Fields>
         <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" 
                        ShowNextPageButton="False" ShowPreviousPageButton="False" NextPageText=">>" PreviousPageText="<<" />
         <asp:NumericPagerField />
       </Fields>
     </asp:DataPager>
   </div>
 </LayoutTemplate>
4

1 に答える 1

0

リストビューのページングでその問題を推測しているだけです。次のように、PagePropertiesChanging イベントでリストビューを再バインドするときに使用しているクエリを確認してください。

protected void ListView1_PagePropertiesChanging(object sender, PagePropertiesChangingEventArgs e)
{
    //set current page startindex, max rows and rebind to false
    lvDataPager1.SetPageProperties(e.StartRowIndex, e.MaximumRows, false);

    //rebind List View
    BindListView();
}

リストビューでのページングの詳細については、次のリンクを参照してください。

http://dotnet.dzone.com/articles/paging-listview-using

于 2013-04-05T09:40:18.710 に答える