How to populate the AutoCompleteTextBox in code behind.

I'm trying to populate the AutoCompleteTextBox in code behind. The data is coming from a Web service as a strongly-typed dataset. I notice a DataSourceID property, but not a DataSource property. Any ideas?

This is urgent!


1 Reply

JA Janagan Syncfusion Team May 22, 2008 02:29 PM UTC

Hi Andy,

Thanks for your interest in Syncfusion products.

You can populate the autocomplete textbox with dataset in code behind by the ProvideChoiceListOnCallback as mentioned in the code below:



protected void AutoCompleteTextBox1_ProvideChoiceListOnCallback(object sender, Syncfusion.Web.UI.WebControls.Tools.ACUserChoiceListEventArgs e)
{
ArrayList List = new ArrayList();
string key = e.Key;
DataSet dataset = new DataSet();
string url = "Id.xml";
dataset.ReadXml(this.Context.Server.MapPath(url));
DataTable dataTable = new DataTable();
dataTable = dataset.Tables[0];
DataRow[] Matchrow = dataset.Tables[0].Select(" Id like '" + key + "%'");
foreach (DataRow row in Matchrow)
{
string Id = row[0].ToString();
List.Add(Id);
}
e.ChoiceList = List;
}



Please refer the sample in the link below which illustrates the above:

http://websamples.syncfusion.com/samples/Tools.Web/6.2.0.40/Tools_ASP_Autocompletetextbox/main.htm


Please try running the sample and let me know if this helps.

Regards,
Janagan.




Loader.
Up arrow icon