我正在研究一个搜索,该搜索显示所有匹配按键的信息。我告诉你现在我不是专业人士仍在学习
我已经到达这一点
Private Sub BindGrid(SearchTerm As String)
Using conss As New SqlConnection(_start)
Dim query As String = "SELECT Item.Name, Item.Quantity, Item.Price, Item.Condition ``FROM Item INNER JOIN Seller ON Item.SellerID = Seller.SellerID INNER JOIN Member ON Seller.MemberID = Member.MemberID WHERE (Item.Status = 'Available') or (Item.Status = 'Quantity') ORDER By NEWID() "
Dim mycommand2 As New SqlCommand(query, conss)
Dim category As SqlDataReader
category = mycommand2.ExecuteReader()
Dim dt As New DataTable()
dt.Columns.Add(New DataColumn("Name"))
dt.Columns.Add(New DataColumn("Quantity"))
dt.Columns.Add(New DataColumn("Price"))
dt.Columns.Add(New DataColumn("Condition"))
For i As Integer = 1 To 12
Dim dr As DataRow = dt.NewRow()
dr("col1") = i
dt.Rows.Add(dr)
Next
'-- use DefaultView to filter the records
Dim dw As DataView = dt.DefaultView
dw.RowFilter = "Col1 like '%" + txtSearch.Text.Trim() + "%'"
Repeater1.DataSource = dw
Repeater1.DataBind()
End Using
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="http://codeorigin.jquery.com/jquery-2.0.3.min.js"></script>
<script>
$(document).ready(function () {
$("#<%=txtSearch.ClientID%>").keypress(function () {
//-- trigger click event of dummy button
//-- we will write bind grid function on this click event on server side
$("#<%=btnDummy.ClientID%>").click();
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:TextBox runat="server" ID="txtSearch" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="btnDummy" runat="server" Text="testbutton" style="display:none" OnClick="btnDummy_Click" />
<asp:Repeater ID="Repeater1" runat="server">
</asp:Repeater>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
我不知道如何将我的SQL绑定到我的中继器,我希望在文本框中的键按键列上完成搜索,有人可以帮助我修改我的代码
您应该查看此示例,以了解如何将中继器绑定到SQL,对于您的搜索功能,您应该在此处看到extractrepeater类的示例。