ASP.NET中的AutoCompleteExtender附加信息

ste*_*yer 2 asp.net autocompleteextender ajaxcontroltoolkit

如何将其他信息传递给返回项集合的服务方法?我将尝试解释我的意思,我在表单上有2个文本框,我需要根据数据库中的特定帐户ID填写名称.所以,我需要将一个整数传递给getNamesForDropDown方法.我无法弄清楚要做什么,所以我做错了,并使用CompletionSetCount实际传递了我需要的信息:

[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public string[] getNamesForDropDown(string prefixText, int count) 
{
   String sql = "Select fldName From idAccountReps Where idAccount = " + count.ToString();
   //... rest of the method removed, this should be enough code to understand
   //... the evil wrongness I did. 
}
Run Code Online (Sandbox Code Playgroud)

在我的正面aspx文件中,我根据用户当前在该页面上查看的帐户ID设置了CompletionSetCount.

<ajaxtk:AutoCompleteExtender 
    runat="server" 
    ID="AC1" 
    TargetControlID="txtAccName"
    ServiceMethod="getNamesForDropDown"
    ServicePath="AccountInfo.asmx"
    MinimumPrefixLength="1" 
    EnableCaching="true"
    CompletionSetCount='<%# Eval("idAccount") %>'
/>
Run Code Online (Sandbox Code Playgroud)

所以,这绝对是一种错误的方式......什么是正确的方法?

For*_*ake 5

azam有正确的想法 - 但自动完成方法的签名也可以有第三个参数:

public string [] yourmethod(string prefixText,int count,string contextKey)

你可以使用Azam的方法分割contextKey字符串的结果 - 但是这样你就不必担心用户输入.Split()的分隔符(:)