microsoft visual studio 2010 asp.net数据库使用部分匹配搜索

时间:2013-03-16 23:51:15

标签: database visual-studio-2010

我正在尝试查询数据库,以便在搜索“街道”时,显示所有带有“街道”的地址。

Address: <asp:TextBox ID="txtAddress" runat="server"></asp:TextBox>
<asp:SqlDataSource ID="sqlAddress" runat="server" 
    ConnectionString="<%$ ConnectionStrings:ConnectionDataBase %>" 
    SelectCommand="SELECT Address, City, State, County, Type FROM Addresses WHERE (Address = @Address)"
    FilterExpression="Address like '%{0}%'"
    EnableCaching="True">
    <SelectParameters>
    </SelectParameters>
    <FilterParameters>
          <asp:ControlParameter ControlID="txtAddress" Name="Address" PropertyName="Text" Type="String" />
   </FilterParameters>
</asp:SqlDataSource>

<asp:GridView ID="grdAddress" DataSourceID="sqlAddress" 
    AutoGenerateColumns="False" runat="server">
    <Columns>
        <asp:BoundField DataField="Address" HeaderText="Address" 
            SortExpression="Address" />
      </Column>
</asp:GridView>

0 个答案:

没有答案