Get Combobox Selected item

  1. #1

    Get Combobox Selected item

    Hello,

    I add items to my combobox dinamically usind store databinding, and i add the next ajaxevent to fire the selection changed event

    
                                   <ext:ComboBox Width = "150px" ID="SensorTypesComboBox" runat="server" 
                                         StoreID="MatchSensor" DisplayField="SensorName" Mode="Local" 
                                         onitemselected="SensorTypesComboBox_ItemSelected">
                                       <AjaxEvents>
                                            <Select OnEvent="SensorSelect">
                                            </Select>
                                       </AjaxEvents>
                                   </ext:ComboBox>
    
    
    
            protected void SensorSelect(object sender, AjaxEventArgs e)
            {
                string SelectedSendor = this.SensorTypesComboBox.SelectedItem.Value;  
            
            }
    but I obtain an empty string from the SelectedItem.Value.

    How can I obtain the Selected Item Value??

    thanks
  2. #2

    RE: Get Combobox Selected item

    Hi yarlenvas,

    The following ComboBox sample appears to work correctly for me. Can you modify the sample to cause the problem you are experiencing?

    Example

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
        protected void ComboBox1_Select(object sender, AjaxEventArgs e)
        {
            this.Label1.Text = "Select: " + this.ComboBox1.SelectedItem.Value;
        }
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <ext:ScriptManager ID="ScriptManager1" runat="server" />
            
            <ext:ComboBox ID="ComboBox1" runat="server">
                <Items>
                    <ext:ListItem Text="Item0" />
                    <ext:ListItem Text="Item1" />
                    <ext:ListItem Text="Item2" />
                    <ext:ListItem Text="Item3" />
                </Items>
                <AjaxEvents>
                    <Select OnEvent="ComboBox1_Select" />
                </AjaxEvents>
            </ext:ComboBox>
    
            <ext:Label ID="Label1" runat="server" />
        </form>
    </body>
    </html>
    Geoffrey McGill
    Founder
  3. #3

    RE: Get Combobox Selected item

    Hi, Thanks for your reply, it's work very nice, but i am added items to the combobox dinamically using an store databinding. I am already using JavaScript to obtain the selected value of the combobox and work very good.

    Thanks.
  4. #4

    RE: Get Combobox Selected item

    Seems like when you populate the combobox from a store and one of the fields is of type int, the value will not appear in combobox1.selecteditem.value or combobox1.selecteditem.text

Similar Threads

  1. [CLOSED] Always selected Item is nothing for combobox as menu item
    By rnachman in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Sep 04, 2011, 4:51 PM
  2. [CLOSED] get the value of the selected item from a combobox via js
    By Edward in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Oct 03, 2010, 12:06 PM
  3. [CLOSED] ComboBox set selected item value
    By pumpkin in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Sep 27, 2009, 7:26 AM
  4. Get ComboBox Selected Item
    By speedstepmem3 in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Nov 18, 2008, 9:50 AM
  5. [FIXED] [V0.6] ComboBox and Selected Item
    By amitpareek in forum Bugs
    Replies: 2
    Last Post: Sep 16, 2008, 5:03 PM

Posting Permissions