index of SelectBox / ComboBox

  1. #1

    index of SelectBox / ComboBox

    I am Making Reports in asp.net using UI of Ext.net
    I am trying to fill two SelectBox , the items of second SelectBox depends on the item selected fromthe first SelectBox (like Country and states).
    now the problem i am facing is , "How to get the Index of all selected items of Second SelectBox (states) ".
    and also the values of all selected items


    i am trying this when selectbox is in single select mode "selectbox.selecteditem.Value" ---> it returns right answer
    But Help me same in case of multiple select SelectBox




    sawairahul.yadav@gmail.com
  2. #2
    Hello!

    Try this one:

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                Store store = this.SelectBox1.GetStore();
    
                store.DataSource = new object[]
            {
                new object[] { "AL", "Alabama", "The Heart of Dixie" },
                new object[] { "AK", "Alaska", "The Land of the Midnight Sun" },
                new object[] { "AZ", "Arizona", "The Grand Canyon State" },
                new object[] { "AR", "Arkansas", "The Natural State" },
                new object[] { "CA", "California", "The Golden State" },
                new object[] { "CO", "Colorado", "The Mountain State" }
            };
    
                store.DataBind();
            }
        }
        
        protected void Click(object sender, DirectEventArgs e)
        {
            var l = SelectBox1.SelectedItems.Select(o => o.Value).ToList();
            X.Msg.Alert("Values", string.Join(",", SelectBox1.SelectedItems.Select(o => o.Value).ToArray())).Show();
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET Examples</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            
            <ext:SelectBox
                ID="SelectBox1"
                runat="server" 
                DisplayField="state"
                ValueField="abbr"
                MultiSelect="True"
                EmptyText="Select a state...">
                <Store>
                    <ext:Store runat="server">
                        <Model>
                            <ext:Model runat="server">
                                <Fields>
                                    <ext:ModelField Name="abbr" />
                                    <ext:ModelField Name="state" />
                                    <ext:ModelField Name="nick" />
                                </Fields>
                            </ext:Model>
                        </Model>            
                    </ext:Store>    
                </Store>    
            </ext:SelectBox>
            
            <ext:Button runat="server" Text="Click me">
                <DirectEvents>
                    <Click OnEvent="Click"></Click>
                </DirectEvents>
            </ext:Button>
        </form>
    </body>
    </html>

Similar Threads

  1. Replies: 4
    Last Post: Oct 24, 2011, 3:34 AM
  2. [CLOSED] SelectBox, ComboBox and ControlParameter
    By rthiney in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: May 27, 2010, 5:04 PM
  3. [CLOSED] set combobox by index and not by value
    By idrissb in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Nov 21, 2009, 5:28 PM
  4. Replies: 0
    Last Post: May 22, 2009, 7:59 AM
  5. Replies: 0
    Last Post: May 16, 2009, 12:31 PM

Posting Permissions