[CLOSED] MultiCombo not selecting items in code behind

  1. #1

    [CLOSED] MultiCombo not selecting items in code behind

    hi,

    I am using multicombo in my application. I am trying to select some of those items from code behind, but it does not select them ( selecting menaing...want those items to be checkmarked and highlighted.) can you pls resolve this issue ?
    I am binding data to it on page load.

    here is the code:
    -----------------------
       <ext:MultiCombo ID="ddlRepPrograms" runat="server" FieldLabel ="Reporting Programs"
                                 Width="500" ValueField="REP_PROGRAM_ID"  DisplayField="REP_PROGRAM_NAME" Margins="0 0 10 0">
    
                                     <Store>
    
                                    
          <ext:Store ID="StoreRepPrograms" runat="server" AutoLoad="true">
                                        <Proxy>
                <ext:AjaxProxy Json="true" Url='<%#RepProgramsUrl%>' AutoDataBind="true" >
                    <ActionMethods Read="POST" Create="POST"/>     
                                     <Headers>
                                     
                                     <ext:Parameter Name="Accept" Value="application/json" />
                                     <ext:Parameter Name="Content-Type" Value="application/json" />
                                     
    
                                     </Headers>                       
                                <Reader>
                                    <ext:JsonReader Root=""/>
                                </Reader>
                                <Writer>
                                <ext:JsonWriter Root="" Encode="true"/>                            
                                </Writer>
    
                                  
                </ext:AjaxProxy>
            </Proxy>
                                            <Model>
                                                <ext:Model ID="Model5" runat="server">
                                                    <Fields>
                                                     <ext:ModelField Name="REP_PROGRAM_ID" Type="Int"/>
                                                        <ext:ModelField Name="REP_PROGRAM_NAME" Type="String"/>
                                                        
                                                    </Fields>
                                                </ext:Model>
                                            </Model>
                                            
                                        </ext:Store>
                                        
                                      
                                    </Store>
                                  
                                    </ext:MultiCombo>
    Here is the code where I am trying to highlight some of the items in multiselect combo from code behind, on a grid row select event.:
    ---------------------------------------------------------------------------------------------------------------------------------------------------------



     protected void ProjectSelect(object sender, DirectEventArgs e) // use this for populatg prj form if prj grid row is selected.
            {
    .
    .
    .
    .
    
     Dictionary<string, string>[] grid1Data = JSON.Deserialize<Dictionary<string, string>[]>(response);
                
    
                        if (grid1Data.Count() > 0)
                        {
                            Ext.Net.ListItem lt = new Ext.Net.ListItem();
                            foreach (var record in grid1Data)
                            {
                                repProgramID = (record["PROGRAM_ID"]);
                                object RepPgmID = Convert.ToInt32(repProgramID);
                              
                                this.ddlRepPrograms.SelectedItems.Add(new Ext.Net.ListItem(record["PROGRAM_NAME"]));
                               
             
                            
                            }
    
                        }
    
                        else
                        {
                            this.ddlRepPrograms.Select("No Program");
                
                        }
    .
    .
    .
    .

    The attached screenshot shows 4 options in multicombo:

    No Program, Test 1, test 2, zzzzzzz

    I want test 1 and test 2 selected in multicombo, on grid row select event in Museum Projects grid.

    when i try the above, still it shows the multicombo unselected with those items.., as it was on page load.


    pls help me resole this asap.

    Thanks,
    Veda
    Attached Thumbnails Click image for larger version. 

Name:	multocombo _ issue .png 
Views:	13 
Size:	43.0 KB 
ID:	7039  
    Last edited by Daniil; Oct 18, 2013 at 4:52 AM. Reason: [CLOSED]
  2. #2
    Hi Veda,

    Please try to call:
    this.ddlRepPrograms.UpdateSelectedItems();
    after modifying the SelectedItems collection.
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi Veda,

    Please try to call:
    this.ddlRepPrograms.UpdateSelectedItems();
    after modifying the SelectedItems collection.
    sorry, that did not work, either !
  4. #4
    Hello!

    I tried the code below and it works fine. Can you provide your sample to reproduce?

    <%@ 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)
            {
                Store1.DataSource = new object[]
                    {
                        new { REP_PROGRAM_ID = 1, REP_PROGRAM_NAME = "Program 1"},
                        new { REP_PROGRAM_ID = 2, REP_PROGRAM_NAME = "Program 2"},
                        new { REP_PROGRAM_ID = 3, REP_PROGRAM_NAME = "Program 3"}
                    };
                Store1.DataBind();
            }
        }
    
        protected void ProjectSelect(object sender, DirectEventArgs e)
        {
            this.ddlRepPrograms.SelectedItems.Add(new Ext.Net.ListItem(1));
            this.ddlRepPrograms.UpdateSelectedItems();
        }
    </script>
    
    <!DOCTYPE>
     
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
     
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        <ext:ResourceManager runat="server" />
              
            <ext:Store ID="Store1" runat="server">
                <Model>
                    <ext:Model ID="Model1" runat="server">
                        <Fields>
                            <ext:ModelField Name="REP_PROGRAM_ID" Type="Int" />
                            <ext:ModelField Name="REP_PROGRAM_NAME" Type="String" />
                        </Fields>
                    </ext:Model>
                </Model>
            </ext:Store>
             
            <ext:MultiCombo ID="ddlRepPrograms" runat="server" Width="260" StoreID="Store1" ValueField="REP_PROGRAM_ID" DisplayField="REP_PROGRAM_NAME">
               
            </ext:MultiCombo>
            
            <ext:Button runat="server" Text="Click Me">
                <DirectEvents>
                    <Click OnEvent="ProjectSelect"></Click>
                </DirectEvents>
            </ext:Button>
        </div>
        </form>
    </body>
    </html>

Similar Threads

  1. Replies: 0
    Last Post: Jun 01, 2013, 10:41 AM
  2. [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
  3. The FormPanel can not add items from code behind
    By sk2276699 in forum 1.x Help
    Replies: 3
    Last Post: Jun 26, 2011, 1:50 AM
  4. [CLOSED] Selecting all items in a MultiSelect dynamically
    By Etisbew in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Aug 19, 2009, 7:14 AM
  5. Selecting an item in a combo box in code
    By antonyn in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Dec 17, 2008, 6:21 AM

Tags for this Thread

Posting Permissions