Hello,
I've encountered some surprising behaviour with the RadAutoCompleteBox.Entries property during the implementation of a custom DataSourceSelect event. Unless I also implement the EntryAdded and EntryRemoved events, the items added to or removed from the box by the user do not show up in the Entries collection of the control in the DataSourceSelect event handler.
I have an AutoCompleteBox defined as follows:
<telerik:RadAutoCompleteBox ID="titles" runat="server" InputType="Token" TokensSettings-AllowTokenEditing="false" DataTextField="Title" DataValueField="TitleID" OnDataSourceSelect="titles_DataSourceSelect" OnEntryAdded="titles_EntryAdded" Width="400px"></telerik:RadAutoCompleteBox>
I have a method that queries my back end database with the text entered by the user and sets the data source. Before querying the database, I get the items that have already been added to the control and include their IDs in the database queries, so that they can be filtered out of the drop down of matches. In other words, if a user has types in text, picked an item form the dropdown and added it to the control, I ensure that the same item does not appear again in the dropdown.
I have put a RadAjaxManager on the page and given the AutoCompleteBox the ability to ajaxically update itself.
But the above doesn't work. When my DataSourceSelect event handler fires, the Entries collection of the control is always empty.
If I implement empty event handlers for EntryAdded and EntryRemoved, it works as expected, and the Entries collection contains the items which have been previously selected by the user.
If I eliminate either one of these two event handlers, the corresponding action is not taken into account in the Entries collection. So if I remove EntryAdded, items I add to the control are not taken into account. If I remove EntryRemoved, when I add and then remove an item, it still shows up in the Entries collection.
On a full page postback triggered by something else, the Entries collection always correctly lists items really entered in the web form.
I am running this in a SharePoint 2010 custom Application page.
This looks like a bug to me, but maybe I've misunderstood the API for this control and am not using it correctly.
I've encountered some surprising behaviour with the RadAutoCompleteBox.Entries property during the implementation of a custom DataSourceSelect event. Unless I also implement the EntryAdded and EntryRemoved events, the items added to or removed from the box by the user do not show up in the Entries collection of the control in the DataSourceSelect event handler.
I have an AutoCompleteBox defined as follows:
<telerik:RadAutoCompleteBox ID="titles" runat="server" InputType="Token" TokensSettings-AllowTokenEditing="false" DataTextField="Title" DataValueField="TitleID" OnDataSourceSelect="titles_DataSourceSelect" OnEntryAdded="titles_EntryAdded" Width="400px"></telerik:RadAutoCompleteBox>
I have a method that queries my back end database with the text entered by the user and sets the data source. Before querying the database, I get the items that have already been added to the control and include their IDs in the database queries, so that they can be filtered out of the drop down of matches. In other words, if a user has types in text, picked an item form the dropdown and added it to the control, I ensure that the same item does not appear again in the dropdown.
protected
void
titles_DataSourceSelect(
object
sender, AutoCompleteBoxDataSourceSelectEventArgs e)<br> {<br> List<
int
> exclude =
new
List<
int
>();<br>
foreach
(AutoCompleteBoxEntry entry
in
titles.Entries)<br> {<br>
int
id = -1;<br>
if
(
int
.TryParse(entry.Value,
out
id))<br> {<br> exclude.Add(id); <br> }<br> }<br><br> titles.DataSource = Database.SearchDimension(
"Title"
, e.FilterString, exclude);
// call DAL<br> }<br>
I have put a RadAjaxManager on the page and given the AutoCompleteBox the ability to ajaxically update itself.
<
telerik:AjaxSetting
AjaxControlID
=
"titles"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"titles"
UpdatePanelRenderMode
=
"Inline"
/>
</
UpdatedControls
>
</telerik:AjaxSetting>
But the above doesn't work. When my DataSourceSelect event handler fires, the Entries collection of the control is always empty.
If I implement empty event handlers for EntryAdded and EntryRemoved, it works as expected, and the Entries collection contains the items which have been previously selected by the user.
<
telerik:RadAutoCompleteBox
ID
=
"titles"
runat
=
"server"
InputType
=
"Token"
TokensSettings-AllowTokenEditing
=
"false"
DataTextField
=
"Title"
DataValueField
=
"TitleID"
OnDataSourceSelect
=
"titles_DataSourceSelect"
OnEntryAdded
=
"titles_EntryAdded"
OnEntryRemoved
=
"titles_EntryRemoved"
Width
=
"400px"
></
telerik:RadAutoCompleteBox
>
protected
void
titles_EntryAdded(
object
sender, AutoCompleteEntryEventArgs e)<br> {<br> }<br><br>
protected
void
titles_EntryRemoved(
object
sender, AutoCompleteEntryEventArgs e)<br> {<br> }
If I eliminate either one of these two event handlers, the corresponding action is not taken into account in the Entries collection. So if I remove EntryAdded, items I add to the control are not taken into account. If I remove EntryRemoved, when I add and then remove an item, it still shows up in the Entries collection.
On a full page postback triggered by something else, the Entries collection always correctly lists items really entered in the web form.
I am running this in a SharePoint 2010 custom Application page.
This looks like a bug to me, but maybe I've misunderstood the API for this control and am not using it correctly.