[CLOSED] Selecting all items in a MultiSelect dynamically

  1. #1

    [CLOSED] Selecting all items in a MultiSelect dynamically

    Hi,

    I had a Multi-Select control and I would like to make all the list items selected when first list item(All objects) is clicked

    I am filling the items dynamically

    The code is executing fine but the items are not getting selected.

    Please let me know if I was missing something required



    Markup
    
      <ext:MultiSelect runat="server" MultiSelect="true" ID="msObjectTypes" Height="150" Width="150">
                                        <AjaxEvents>
                                        <Change OnEvent="msObjectTypes_SelectionChanged"></Change>
                                        </AjaxEvents>
                                        </ext:MultiSelect>
    
    
    Code Behind
    
      public void msObjectTypes_SelectionChanged(object sender, AjaxEventArgs e)
        {
            if (msObjectTypes.SelectedItems.Count > 0)
            {
                for (int selectedItemCount = 0; selectedItemCount < msObjectTypes.SelectedItems.Count; selectedItemCount++)
                {
                    if ((int)Enums.MosaiqueObjects.AllObjects == Convert.ToInt16(msObjectTypes.SelectedItems[selectedItemCount].Value))
                    {
                        int tmpIndex=0;
                        foreach (Coolite.Ext.Web.ListItem list in msObjectTypes.Items)
                        {
                            msObjectTypes.SelectedItems.Add(new SelectedListItem(list.Text,list.Value,tmpIndex++));
                        }
                        break;
                    }
                }
            }
        }
  2. #2

    RE: [CLOSED] Selecting all items in a MultiSelect dynamically

    Hi,

    You need to call UpdateSelection after filling SelectedItems collection
    msObjectTypes.UpdateSelection();

Similar Threads

  1. [CLOSED] Problem selecting items in Combobox
    By tlfdesarrollo in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jan 17, 2012, 6:57 PM
  2. Selecting multiple values in Multiselect
    By masudcseku in forum 1.x Help
    Replies: 1
    Last Post: Nov 23, 2011, 7:26 AM
  3. Replies: 1
    Last Post: Apr 15, 2010, 8:07 PM
  4. [CLOSED] Dynamically add/remove items from multiselect.
    By Jurke in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Nov 30, 2009, 11:12 AM
  5. Replies: 0
    Last Post: Jun 03, 2009, 5:30 PM

Posting Permissions