0
我做了一個搜索頁面鏈接到數據庫,當頁面加載時我使用VB Codebehind設置SqlSelectCommand
爲ListView
所以它返回0結果,當客戶端搜索一個項目我改變Sql選擇爲LIKE '%search%'
。Datapager回覆原來的數據
這一切工作正常,但發生的事情是,當你點擊第2頁上它恢復到原來的SQL語句
我使用的是Label
爲此我也動態地根據搜索鍵來改變航向確保數據返回到頁面
您可以預覽我的網站在這裏 http://www.barkingdog.co.za/asp/Search1.aspx
同樣的問題在Office頁面,在這裏雖然我開始頁面,在SQL SELECT數據,但是當我點擊例如。經濟,然後嘗試去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>