最佳解答者
AutoCompleteExtender 不會自動選擇問題

問題
-
我按以下的例子, 做了一個例子,
http://www.asp.net/AJAX/AjaxControlToolkit/Samples/AutoComplete/AutoComplete.aspx
<WebMethod()> _
Public Function getProductID() As List(Of String)
returnStr.Add("人民")
returnStr.Add("中文")
returnStr.Add("公司")
returnStr.Add("公關")
returnStr.Add("國家")
Return returnStr
End Function
<asp:AutoCompleteExtender ID="autoComplete1" runat="server" TargetControlID="txtProductID"
ServicePath="~/WebServices/wsGetProductID.asmx" ServiceMethod="getProductID" MinimumPrefixLength="1" />
為甚麼我輸入 "公" 會把所有內容都全部顯示出來, 輸入"公司" 又不會自動把 "公司" 選擇出來.
請教大家...
thanks2009年3月12日 下午 03:15
解答
-
你好
這會不會是因為沒有放filter 去 filter data?
可以試試下面的code
<WebMethod()> _
Public Function getProductID(ByVal Prefix as String) As List(Of String)
'generate a list to be filter
Dim returnStr As New List(Of String)
returnStr.Add("人民")
returnStr.Add("中文")
returnStr.Add("公司")
returnStr.Add("公關")
returnStr.Add("國家")
Dim rStr As New List(Of String)
For i As Int32 = 0 To returnStr.Count - 1
'filter the list
If returnStr.Item(i).StartsWith(Prefix) Then
rStr.Add(returnStr.Item(i))
End If
Next
return rStr
End Function
hope this can help
Chi- 已標示為解答 Lam0706 2009年3月13日 上午 08:43
2009年3月12日 下午 05:14 -
你好Lam0706
List <of String> 和 String() [String Array] 的最大分別是
String() [String Array] 是FIXED SIZE 的
所以你唔可以 就咁ADD 多D STRING 入去
而[List] List <of String> 就提供了得多 METHODS
E.G. Add, Remove
你便可以好容易咁加減 同改List <of String> 入面的 item 了
Hope this can help.
Please forgive me if my concept is wrong.
Chi- 已標示為解答 Lam0706 2009年3月16日 上午 08:48
2009年3月15日 下午 08:36
所有回覆
-
你好
這會不會是因為沒有放filter 去 filter data?
可以試試下面的code
<WebMethod()> _
Public Function getProductID(ByVal Prefix as String) As List(Of String)
'generate a list to be filter
Dim returnStr As New List(Of String)
returnStr.Add("人民")
returnStr.Add("中文")
returnStr.Add("公司")
returnStr.Add("公關")
returnStr.Add("國家")
Dim rStr As New List(Of String)
For i As Int32 = 0 To returnStr.Count - 1
'filter the list
If returnStr.Item(i).StartsWith(Prefix) Then
rStr.Add(returnStr.Item(i))
End If
Next
return rStr
End Function
hope this can help
Chi- 已標示為解答 Lam0706 2009年3月13日 上午 08:43
2009年3月12日 下午 05:14 -
你好Lam0706
List <of String> 和 String() [String Array] 的最大分別是
String() [String Array] 是FIXED SIZE 的
所以你唔可以 就咁ADD 多D STRING 入去
而[List] List <of String> 就提供了得多 METHODS
E.G. Add, Remove
你便可以好容易咁加減 同改List <of String> 入面的 item 了
Hope this can help.
Please forgive me if my concept is wrong.
Chi- 已標示為解答 Lam0706 2009年3月16日 上午 08:48
2009年3月15日 下午 08:36