Mar 19, 2009, 9:32 AM
Problem Combobox.SelectedItem Same Displayfield, Different Values
Hallo Coolite Team,
I have got a problem with the SelectedItem of the ComboxBox. I use the Custom Search Example as basis. This is my Combobox:
Here is the code of the select event:
I have got a problem with the SelectedItem of the ComboxBox. I use the Custom Search Example as basis. This is my Combobox:
<ext:ComboBox ID="DelName" runat="server" StoreID="Store7" DisplayField="Name" ValueField="ObjectID"
TypeAhead="false" LoadingText="Suche..." Width="200" PageSize="10" HideTrigger="true"
ItemSelector="div.search-item" AllowBlank="false" BlankText="Der Lieferant muss eingegeben werden"
FieldLabel="Name*" MinChars="1">
<Template ID="Template1" runat="server">
<tpl for=".">
<div class="search-item">
<h3>{Name}</h3>{Contact}<br />{Street}<br />{Zipcode} {City}
</tpl>
</Template>
<AjaxEvents>
<Select OnEvent="DelAddress_Select">
<EventMask ShowMask="true" Msg="Hole Adresse..." Target="Parent" />
</Select>
</AjaxEvents>
<ToolTips>
<ext:ToolTip ID="Tooltip48" runat="server" Html="Bitte wählen Sie die Lieferadresse durch Eingabe des Namens und der Auswahl. Ein * zeigt alle Lieferadressen an.">
</ext:ToolTip>
</ToolTips>
</ext:ComboBox>
The items can have the same "Name" (DisplayField) but the ObjectID (ValueField) is always unique. When I choose an item (other items have the same name) I get the right Name and the right ObjectID during the Select event. The next step is to save the selection. I call the selecteditem again and now i get the Name and the ObjectID only of the first item with the same name in the list even if i have slected the last item with the same name. Here is the code of the select event:
protected void DelAddress_Select(object sender, Coolite.Ext.Web.AjaxEventArgs e)
{
Guid ObjectID=DelName.SelectedItem.Value;
}
Later I click a button to save the selection: protected void btnAddress_Click(object sender, Coolite.Ext.Web.AjaxEventArgs e)
{
Guid ObjectID=DelName.SelectedItem.Value;
}
Thank you