2009-01-31 93 views
1

我使用AutoCompleteExtenderAjax控件工具包,它是stragely行为。Ajax控件工具包AutoCompleteExtender剥离零和未来与幻象值

我的服务方法如下所示:

[System.Web.Services.WebMethod] 
[System.Web.Script.Services.ScriptMethod] 
public string[] getEJMaps(string prefixText, int count) 
{ // method that returns the auto-suggest for the EJMaps positions 
    string file_location = HttpContext.Current.Server.MapPath("~") + Utils.Settings.Get("attachments") + "ejmaps\\ejmaps.xml"; 
    XElement x = XElement.Load(file_location); 
    string[] positions = (from p in x.Descendants("position") where p.Value.StartsWith(prefixText) orderby p.Value select p.Value).ToArray(); 
    if (positions.Count() == 0) 
     return new string[] { "No Matching Results" }; 
    else return positions; 
} 

,它工作正常,如果我的价值观调用它的测试页getEJMaps(“00056”,4)我得到这些结果:

00056399 
00056717 
00056721 
00056722 
00056900 
... 

这就是我想要的东西,但是当我把它绑在文本框和类型在00056,我得到的结果:

56399 
24015 
24017 
56717 
56721 
... 

这说明两个问题:

  1. 到底发生到我的零是什么?我怎样才能让他们回来?
  2. 这些“240xx”数字来自哪里?甚至在xml文档中都没有这些值!

我完全被这个难住了,请帮我:)

回答

2

你需要用引号括阵列中的每个字符串。例如,getEJMaps应该返回一个数组,看起来像:

"00056399" 
"00056717" 
"00056721" 
"00056722" 
"00056900" 
... 

不要忘记,你需要逃避与\

引号如果这能解决丢失0的,但不是幻象值,让我知道,我会尽力协助。我想它会。

+0

他们都串 - 这是奇怪的一部分; 我放弃了工具包,并用jQuery代替http://naspinski.net/post/Using-jqueryautosuggestjs-with-AspNet.aspx – naspinski 2009-02-04 06:11:15

1
SELECT 
'''' + CustomerShipTo + '''' AS CustomerShipTo 

FROM dbo.CustomerMaster 

这应该工作..... 它为我