[CLOSED] Set the Selected Items in MultiSelect

  1. #1

    [CLOSED] Set the Selected Items in MultiSelect

    Hi,

    In the sample below when i click thetestSelect button the ComapnyId i have passed selectedCompany = "2,4"; is not selected...Hoe to highlight these selected company value...

    <table cellpadding="0" cellspacing="0">
    
    <tr>
    
    <td>
    
    Company
    
    </td>
    
    <td>
    
    <ext:Store ID="clstoCompany" runat="server">
    
    <Reader>
    
    <ext:JsonReader>
    
    <Fields>
    
    <ext:RecordField Name="CID" />
    
    <ext:RecordField Name="Name" />
    
    </Fields>
    
    </ext:JsonReader>
    
    </Reader>
    
    </ext:Store>
    
    <ext:MultiSelect ID="cllstComapny" runat="server" DisplayField="Name" ValueField="CID"
    
    StoreID="clstoCompany" KeepSelection&#111;nclick="WithCtrlKey" Width="150" Height="100">
    
    </ext:MultiSelect>
    
    </td>
    
    </tr>
    
    <tr>
    
    <td colspan="2" align="center">
    
    <ext:Button ID="climbMultiSelect" Text="TestMultiSelect" runat="server">
    
    <AjaxEvents>
    
    <Click OnEvent="climbMultiSelect_Click" />
    
    </AjaxEvents>
    
    </ext:Button>
    
    </td>
    
    </tr>
    
    </table>
    
    
    
     
    
    public partial class UPload : System.Web.UI.Page
    
    {
    
    protected void Page_Load(object sender, EventArgs e)
    
    {
    if (!IsPostBack)
    
    {
    
    BindValues();
    
    }
    
    }
    
    private void BindValues()
    
    {
    
    DataTable dtCompany = new DataTable();
    
    dtCompany.Columns.Add("CID", Type.GetType("System.String"));
    
    dtCompany.Columns.Add("Name", Type.GetType("System.String"));
    
    dtCompany.Rows.Add("1", "EGAR");
    
    dtCompany.Rows.Add("2", "HDFC");
    
    dtCompany.Rows.Add("3", "IBM");
    
    dtCompany.Rows.Add("4", "TCS");
    
    dtCompany.Rows.Add("5", "Western Valley");
    
    clstoCompany.DataSource = dtCompany;
    
    clstoCompany.DataBind();
    
    }
    
    protected void climbMultiSelect_Click(object sender, AjaxEventArgs e)
    
    {
    
    string selectedCompany = "2,4";
    
    SelectMultiList(cllstComapny, selectedCompany);
    
    }
    
    public void SelectMultiList(Coolite.Ext.Web.MultiSelect listBox, string DbValues)
    
    {
    
    string[] arrlst = DbValues.Split(',');
    
    foreach (string id in arrlst)
    
    {
    
    if (!string.IsNullOrEmpty(id))
    
    {
    
    listBox.SelectedItems.Add(new Coolite.Ext.Web.SelectedListItem() { Value = id.ToString() });
    
    }
    
    }
    
    }
    
    }
  2. #2

    RE: [CLOSED] Set the Selected Items in MultiSelect

    Hi,

    You have to call UpdateSelection to update the selection during AjaxEvent
    listBox.UpdateSelection();

Similar Threads

  1. [CLOSED] Add selected items to ExtraParams for MultiSelect
    By jmcantrell in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Sep 20, 2010, 8:40 PM
  2. Loop through selected items in Multiselect
    By ddolan in forum 1.x Help
    Replies: 3
    Last Post: Jul 29, 2010, 1:16 PM
  3. [CLOSED] How can I set selected items in a MultiSelect from a Store?
    By iansriley in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jan 14, 2010, 4:41 PM
  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

Posting Permissions