Loop through selected items in Multiselect

  1. #1

    Loop through selected items in Multiselect

    I am trying to loop through all selected items in a Multiselect and add them to an array. I am new to Coolite and I am learning that they don't function the same way the ASP controls work. I did look at the examples but am having a hard time adapting it to my needs. Any help would be greatly appreciated.
  2. #2
    Hi ddolan,

    Welcome!

    Here's a quick example demonstrating how to loop through the Selected ListItems during a DirectEvent.

    Example

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
     
    <script runat="server">
        protected void Button1_Click(object sender, DirectEventArgs e)
        {
            var items = "";
            
            foreach (SelectedListItem item in this.MultiSelect1.SelectedItems)
            {
                items += item.Value + "<br />";
            }
    
            this.Label1.Html = items;
        }
    </script>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.NET Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            
            <ext:MultiSelect ID="MultiSelect1" runat="server">
                <Items>
                    <ext:ListItem Text="Item 0" />
                    <ext:ListItem Text="Item 1" />
                    <ext:ListItem Text="Item 2" />
                    <ext:ListItem Text="Item 3" />
                </Items>
            </ext:MultiSelect>
            
            <ext:Button runat="server" Text="Submit" OnDirectClick="Button1_Click" />
            
            <ext:Label ID="Label1" runat="server" />
        </form>
    </body>
    </html>
    Hope this helps.
    Geoffrey McGill
    Founder
  3. #3
    If you're just starting our, please ensure you are using the v1.0 Preview release, see

    http://forums.ext.net/showthread.php...on-1.0-Preview
    Geoffrey McGill
    Founder
  4. #4
    I was actually able to figure it out with this code.
    Dim c As New Ext.Net.ListItem.Config
                c.Text = CurrentMember.Name.Remove(0, 3)
                c.Value = CurrentMember.Properties("mail").Value.ToString
                MultiSelect1.Items.Add(New Ext.Net.ListItem(c))
    
     For Each a As Ext.Net.SelectedListItem In MultiSelect1.SelectedItems
    Thanks for your prompt response and the time you took to look at this. I appreciate it very much.

Similar Threads

  1. Replies: 0
    Last Post: Apr 29, 2011, 8:37 PM
  2. [CLOSED] Set MultiSelect selected items during DirectEvent
    By jmcantrell in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: Sep 20, 2010, 4:07 PM
  3. [CLOSED] Set the Selected Items in MultiSelect
    By majestic in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Mar 11, 2010, 2:57 AM
  4. Multiselect with Store - can't get selected items
    By CheGuevara in forum 1.x Help
    Replies: 3
    Last Post: Nov 02, 2009, 5:23 PM
  5. Replies: 0
    Last Post: Jun 03, 2009, 5:30 PM

Tags for this Thread

Posting Permissions