具有多列列表的ajax自动完成扩展程序

时间:2013-05-27 05:12:24

标签: asp.net sql ajax autocompleteextender

我正在寻找使用DataTable自动完成功能的示例。自动完成应具有除单列之外的表结构。

任何提示..?谢谢!提前

标记如下

 <asp:TextBox ID="txtAutoCmplte" runat="server"></asp:TextBox>
  <asp:AutoCompleteExtender ID="txtAutoCmplte_AutoCompleteExtender" 
    runat="server" CompletionInterval="1" ServiceMethod="GetNames" 
    TargetControlID="txtAutoCmplte" 
        CompletionListCssClass="autocomplete_completionListElement" 
        MinimumPrefixLength="1" BehaviorID="AutoCompleteEx" 
        onclientpopulated="onListPopulated">
  </asp:AutoCompleteExtender>
  <asp:ScriptManager ID="ScriptManager1" runat="server">
  </asp:ScriptManager>

1 个答案:

答案 0 :(得分:0)

您可以相应地创建查询
示例

 select 
       [columnName]
 from
       [tableName]
 where
       [columnName1] like %[input value]%  or
       [columnName2] like %[input value]% 

或者您希望显示两列的合并结果,然后您可以使用union,如下所示

 select 
       [columnName]
 from
       [tableName]
 where
       [columnName] like %[input value]% 
 union
      select 
       [columnName1]
 from
       [tableName]
 where
       [columnName1] like %[input value]%