アイテムのコレクションを返すサービス メソッドに追加情報を渡すにはどうすればよいですか? フォームに 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.
}
フロントサイドのaspxファイルで、ユーザーが現在そのページで表示しているアカウントIDに基づいてCompletionSetCountを設定しました。
<ajaxtk:AutoCompleteExtender
runat="server"
ID="AC1"
TargetControlID="txtAccName"
ServiceMethod="getNamesForDropDown"
ServicePath="AccountInfo.asmx"
MinimumPrefixLength="1"
EnableCaching="true"
CompletionSetCount='<%# Eval("idAccount") %>'
/>
だから、それは間違いなく間違った方法です.正しい方法は何ですか?