Last post Aug 31, 2015 10:54 PM by Nan Yu
Aug 25, 2015 02:25 PM|nlee2012|LINK
Thank you for your help in advance.
I have a very simple Combobox (autopostback = true, autocompletemode = suggest) that displays data from Oracle database. I specified oniteminserting and oniteminserted to validate an entered item that's not on the listed item. But these events are not getting
fired at all. I searched everywhere and tried many suggestions to no avail. Many hours were spent on this already. Please help. BTW, I'm using NET 45 toolkit.
Aug 26, 2015 04:49 AM|Nan Yu|LINK
Hi nlee2012 ,
Comboxbox ItemInserting ItemInserted event not firing
Could you please post your code about the combobox ,and you could set a breakpoint to the OnItemInserting event and confirm whether the event will be called .Basic usage of the two events is for your reference:
<ajaxToolkit:ComboBox runat="server" ID="AjaxCombo" OnItemInserted="ItemInsertedEvent" OnItemInserting="ItemInsertingEvent" AutoPostBack="True" ItemInsertLocation="Append" />
public void ItemInsertedEvent(object sender, AjaxControlToolkit.ComboBoxItemInsertEventArgs e)
// read from your data table in this event and bind the data to the combo boxs
public void ItemInsertingEvent(object sender, AjaxControlToolkit.ComboBoxItemInsertEventArgs e)
string itemToBeInserted = e.Item.Value;
// make a call to add this item to your data table
You could also refer to links below for more details and demo:
Aug 26, 2015 01:48 PM|nlee2012|LINK
There really isn't much codes to post. I don't have much more than what you've included as example. It's a simple combobox with "OnItemInserted" and "OnItemInserting" events. I put the debugging statement in those events, but never see it because it's never
called. I did find that setting "AutoCompleteMode" to "none" made the event to fire. Well, it defeats the purpose of using "ComboBox" option if the option "AutoCompleteMode" is turned off. The whole idea is to allow user to search by entering some text in
addition to using "dropdown".
Aug 26, 2015 10:04 PM|Nan Yu|LINK
I put the debugging statement in those events, but never see it because it's never called. I did find that setting "AutoCompleteMode" to "none" made the event to fire.
I test my code with setting "AutoCompleteMode" to "suggest" ,and it fires the "OnItemInserted" and "OnItemInserting" events. Have you updated the Ajax control toolkit to the latest version?
Aug 31, 2015 06:02 PM|nlee2012|LINK
Thanks again for your reply.
As per your suggestion, I upgraded the Ajax to the latest version, 15.1.3, and "firing" worked. However, I now have a bigger problem. The reason for using the combobox was to allow user to enter as many characters as they want into the box when searching
for an item. It worked before both in IE and FF, now in IE, I can only enter only "1" character, hence defeating the purpose of using "combobox". Your help will be greatly appreciated.
Here are codes:
<asp:ComboBox ID="cbox" runat="server"
AutoPostBack="True" OnItemInserted="ItemInserting" OnItemInserting="ItemInserting"
DataValueField="ITEM_NUMBER" MaxLength="80" DropDownStyle="Simple" AutoCompleteMode="Suggest" >
<asp:SqlDataSource ID="ItemsList" runat="server"
ConnectionString="<%$ ConnectionStrings:OraSql %>"
ProviderName="<%$ ConnectionStrings:OraSql.ProviderName %>"
SelectCommand= "SELECT ITEM_NUMBER, ITEM_DESC FROM ITEM_LISTS WHERE ITEM_TYPE = :ITEM_TYPE ORDER BY ITEM_NUMBER">
<asp:Parameter DefaultValue="FG" Name="ITEM_TYPE" Type="String" />
Aug 31, 2015 10:54 PM|Nan Yu|LINK
I test your code and it works fine ,the difference is i got the data from sql server , are you do something in ItemInserting or ItemInserted event ? tested code is for your reference:
<cc1:ComboBox ID="ComboBox2" runat="server" DropDownStyle="Simple" AutoCompleteMode="Suggest"
DataTextField="ContactName" MaxLength="80" OnItemInserted="ComboBox2_ItemInserted" OnItemInserting="ComboBox2_ItemInserting" DataValueField="CustomerId" DataSourceID="SqlDataSource1">
<asp:SqlDataSource ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="SELECT CustomerId, ContactName FROM [Customers] WHERE City = @City" runat="server">
<asp:Parameter DefaultValue="London" Name="City" Type="String" />
In addition , you could post a new thread for further discussion with other members ,since question in this thread has been solved .