我创建了一个链接到数据库的搜索页面,当页面加载时,我使用 VB Codebehind 设置它SqlSelectCommand
,ListView
因此它返回 0 结果,当客户端搜索项目时,我将 Sql 选择更改为LIKE '%search%'
.
这一切都很好,但发生的情况是,当您单击第 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>