Click here to Skip to main content
16,004,727 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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)


I get an error stating "CreateAutoCompleteItem method is not defined in AutoCompleteExtender control".

Any help will be appreciated. Thanks in advance!

Regards,
Divya
Posted
Updated 3-Feb-10 22:15pm
v3

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 ?
 
Share this answer
 
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!
 
Share this answer
 
v2
The exact error is :

"AjaxControlToolkit.AutoCompleteExtender does not contain a definition for 'CreateAutoCompletionItem'"
 
Share this answer
 
Please edit your post. This question now has four answers when I post this one, and two of them are you providing more detail.

Have you got the latest version of the AJAX toolkit, or at least the one that article links to ? Have you downloaded the sample code he provides, and does it work ? What makes you think the method exists, despite this error ? Does it appear in your intellisense list ?
 
Share this answer
 
Hi,

yes I have downloaded AjaxControlToolkit 1.0.20229 and using this. The method CreateAutoCompletionItem is not showing in intellisense list. But in my code I need to get the Id against the item which was selected in the AutoCompleteExtender and at the mentioned URL I got this method name to be used as a proposed solution.

Please tell me whether there is any other way to get the id against the item. Thanks!

Regards,
Divya
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900