在AutoCompleteExtender问题中未定义CreateAutoCompleteItem方法 [英] CreateAutoCompleteItem method is not defined in AutoCompleteExtender issue
问题描述
我在aspx页面上使用了ASP.NET 2.0的AjaxControlToolkit的AutoCompleteExtender控件.
该控件工作正常,我正在从数据库中接收值,但是问题是我无法在控件中获取选择值的键.我听说CompleteAutoCompletionItem(key,value)方法可以为控件提供键和值.
当我使用此代码时:
Hi,
I am using AutoCompleteExtender control of AjaxControlToolkit for ASP.NET 2.0 on my aspx page.
This control is working fine and I am receiving values from the database but the problem is that I am unable to get the key for select value in the control. I heard that CompleteAutoCompletionItem(key,value) method can provide keys and value to the control.
When I use this code:
AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(key,value)
我收到一条错误消息,指出未在AutoCompleteExtender控件中定义CreateAutoCompleteItem方法".
任何帮助将不胜感激.提前谢谢!
问候,
Divya
I get an error stating "CreateAutoCompleteItem method is not defined in AutoCompleteExtender control".
Any help will be appreciated. Thanks in advance!
Regards,
Divya
推荐答案
^ ] google hit.
无法看到您的代码,很难知道它的外观.看起来像这个样本吗?确切的错误是什么?
First[^] google hit.
Not being able to see your code, it''s hard to know what it looks like. Does it look like this sample ? What is the exact error ?
我已经浏览了您粘贴的链接.从那里本身,我得到了这个方法的名称.
我的Web服务的代码(截至目前,该字符串将字符串数组返回给AutoCompleteExtender)是:
Hi,
I had gone through the link you pasted. From there itself, I got this method name.
Code for my web service which is returning a string array as of now to AutoCompleteExtender is:
using System;
using System.Collections.Generic;
using System.Web.Services;
using System.Data.SqlClient;
using System.Data;
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService]
public class AutoComplete : WebService
{
public AutoComplete()
{
}
[WebMethod]
public string[] GetCompletionList(string prefixText, int count)
{
string str = // sql connection string
SqlConnection conn = new SqlConnection(str);
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = conn;
cmd.CommandText = "Ajax_GetCustomerList";
cmd.Parameters.Add("@customerNameSubString", SqlDbType.VarChar,100).Value = prefixText.ToString();
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds, "customerSubStringList");
string[]chk = new string[ds.Tables[0].Rows.Count];
int i = 0;
ArrayList list = new ArrayList();
foreach (DataRow dr in ds.Tables[0].Rows)
{
chk[i] = dr[0].ToString();
i++;
//list.Add(AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(dr[1].ToString(),dr[0].ToString())); /* This line I added to get the key, value pair */
}
return chk;
}
}
请协助.谢谢!
Please assist. Thanks!
确切的错误是:
"AjaxControlToolkit.AutoCompleteExtender不包含"CreateAutoCompletionItem"的定义".
The exact error is :
"AjaxControlToolkit.AutoCompleteExtender does not contain a definition for ''CreateAutoCompletionItem''"
这篇关于在AutoCompleteExtender问题中未定义CreateAutoCompleteItem方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!