I have a web service that I want to return 2 values and ID and a text value hrough and autocompletebox. I have it working to return the service but now I need to get at the ID value that was returned, not the text value. I would like to be able to do an Autopostback on the autocompletebox and hit a database with the ID to return more data to the page. Is this possible iwht the autocompletebox as I have not been able to find code that shows this. It would be similar to the asp Autocomplete extender that can return 2 values that you can then use. Can I do this with a telerik AutocompleteBox.
<
telerik:radautocompletebox
ID
=
"rdSearch"
runat
=
"server"
EmptyMessage
=
"Type Last Name First Name"
EnableAutoComplete
=
"true"
MinFilterLength
=
"2"
MaxResultCount
=
"20"
Width
=
"260px"
DropDownHeight
=
"100px"
DropDownWidth
=
"250px"
DropDownPosition
=
"static"
AutoPostBack
=
"true"
OnClientEntryAdded
=
"requesting"
>
<
TextSettings
SelectionMode
=
"Single"
/>
<
WebServiceSettings
Path
=
"../AutoComplete.asmx"
Method
=
"GetNames"
/>
</
telerik:radautocompletebox
>
function requesting(sender, eventArgs) {
var context = eventArgs.get_context();
//Data passed to the service.
// context["ClientData"] = "ClientData_Passed_To_The_Service";
}
[WebMethod]
public AutoCompleteBoxData GetNames(RadAutoCompleteContext context)
{
string sql = "select intPersonnelId, strFullname FullName FROM tblMNNatPersonnel WHERE strFullname like '" + context.Text + "%'";
//SqlDataAdapter adapter = new SqlDataAdapter(sql, ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString);
DataTable myDataTable = new DataTable();
myDataTable = c.GetReader(sql);
List<
AutoCompleteBoxItemData
> result = new List<
AutoCompleteBoxItemData
>();
AutoCompleteBoxData dropDownData = new AutoCompleteBoxData();
result = new List<
AutoCompleteBoxItemData
>();
for (int i = 0; i < myDataTable.Rows.Count; i++)
{
AutoCompleteBoxItemData itemData = new AutoCompleteBoxItemData();
itemData.Text = myDataTable.Rows[i]["FullName"].ToString();
itemData.Value = myDataTable.Rows[i]["intPersonnelId"].ToString();
result.Add(itemData);
}
dropDownData.Items = result.ToArray();
return dropDownData;
}
When it returns to the autocomplete box I need to do take the intPersonnelId and hit a database and return more information.