검색이라는 단추가있는 드롭 다운 상자를 사용하여 검색 쿼리를 수행하려고합니다. 검색 대상 데이터를 가져 오려고합니다. 내가 어디에서 시작 해야할지 모르겠다, 나는 그것을 할 수있는 몇 가지 코딩 및 다른 방법을 둘러 보았지만 그들은 복잡해 보입니다, 이것은 내 약점이며, 약간의 도움과지도가 필요한 ASP의 비트입니다. 아래는 페이지의 코드입니다.VB.net에서 검색 쿼리 도움말이 필요합니까?
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="ForSale.aspx.vb" Inherits="Users_ForSale" title="Properties For Sale" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<h3>Properties For Sale</h3>
<h5>
<asp:Label ID="lblTown" runat="server" Text="Town:"></asp:Label>
<asp:DropDownList ID="ddlTownSearch" runat="server">
<asp:ListItem></asp:ListItem>
<asp:ListItem>Chadderton</asp:ListItem>
<asp:ListItem Value="Failsworth"></asp:ListItem>
<asp:ListItem>Oldham</asp:ListItem>
<asp:ListItem>Royton</asp:ListItem>
<asp:ListItem>Shaw</asp:ListItem>
</asp:DropDownList>
<asp:Label ID="lblBedroomsSearch" runat="server" Text="Bedrooms:"></asp:Label>
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem></asp:ListItem>
<asp:ListItem>1</asp:ListItem>
<asp:ListItem Value="2"></asp:ListItem>
<asp:ListItem Value="3"></asp:ListItem>
<asp:ListItem>4</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
<asp:ListItem>6+</asp:ListItem>
</asp:DropDownList>
<asp:Label ID="lblMinPrice" runat="server" Text="Min Price (£):"></asp:Label>
<asp:TextBox ID="txtMinPriceSearch" runat="server" Width="87px"></asp:TextBox>
<asp:Label ID="lblMaxPriceSearch" runat="server" style="text-align: left"
Text="Max Price (£):"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server" Width="87px"></asp:TextBox>
</h5>
<h5>
<asp:Button ID="btnForsaleSearch" runat="server" Text="Search" />
</h5>
<p>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False" CellPadding="4"
DataKeyNames="ProductId" DataSourceID="SqlDataSource1" ForeColor="#333333"
GridLines="None" Width="588px">
<RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
<Columns>
<asp:ImageField DataImageUrlField="ImageURL">
</asp:ImageField>
<asp:BoundField DataField="ProductId" HeaderText="ProductId" ReadOnly="True"
SortExpression="ProductId" />
<asp:BoundField DataField="Description" HeaderText="Description"
SortExpression="Description" />
<asp:BoundField DataField="Price" HeaderText="Price" SortExpression="Price" />
<asp:BoundField DataField="Town" HeaderText="Town"
SortExpression="Town" />
</Columns>
<FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
</p>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:JPEstatesConnectionString %>"
SelectCommand="SELECT * FROM [Products]"
DeleteCommand="DELETE FROM [Products] WHERE [ProductId] = @ProductId"
InsertCommand="INSERT INTO [Products] ([ProductId], [Description], [Price], [Category], [ImageURL]) VALUES (@ProductId, @Description, @Price, @Category, @ImageURL)"
UpdateCommand="UPDATE [Products] SET [Description] = @Description, [Price] = @Price, [Category] = @Category, [ImageURL] = @ImageURL WHERE [ProductId] = @ProductId">
<DeleteParameters>
<asp:Parameter Name="ProductId" Type="String" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="Description" Type="String" />
<asp:Parameter Name="Price" Type="Decimal" />
<asp:Parameter Name="Category" Type="String" />
<asp:Parameter Name="ImageURL" Type="String" />
<asp:Parameter Name="ProductId" Type="String" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="ProductId" Type="String" />
<asp:Parameter Name="Description" Type="String" />
<asp:Parameter Name="Price" Type="Decimal" />
<asp:Parameter Name="Category" Type="String" />
<asp:Parameter Name="ImageURL" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
</asp:Content>
감사합니다. 그것은 나에게 더 도움이된다. 다시 한번 감사합니다. – Naresh
대답의 링크가 죽었습니다 - * "이 사이트에 연결할 수 없습니다/blog.evonet.com.au의 서버 DNS 주소를 찾을 수 없습니다"* – Pang
@Pang 예, 여기에서 찾을 수 있습니다 https : //web.archive .org/web/20111010220645/http : //blog.evonet.com.au/post/2010/04/24/Using-ParametersAddWithValue-with-a-Like-SQL-query.aspx – Maysam