selectedindexchanged firing all RadComboBox Handlers

6 posts, 0 answers
  1. Rahul
    Rahul avatar
    7 posts
    Member since:
    Nov 2012

    Posted 08 Nov 2012 Link to this post

    Hi Guys,

    I have 2 RadComboBox in my asp page when I select values in any of these object it trigger selectedindexchanged handler for both combobox.

      These are my codes

    <telerik:RadScriptManager runat="server" ID="RadScriptManager" />
    <table>
    <tr>
    <td>Customer Set:</td>
    <td>
        <telerik:RadComboBox ID="Radbox1" runat="server" CheckBoxes="true" EnableCheckAllItemsCheckBox="true"
        Width="300" Height="200" AutoPostBack="True" OnSelectedIndexChanged="Radbox1_SelectedIndexChanged" /> 
     </td>
    </tr>
    <tr>
     <td>Event Set:</td>
    <td>
         <telerik:RadComboBox ID="Radbox2" runat="server" CheckBoxes="true" EnableCheckAllItemsCheckBox="true"
         Width="300" Height="200" AutoPostBack="True" OnSelectedIndexChanged="Radbox2_SelectedIndexChanged" /> 
    </td>
    </tr>

     Protected Sub Radbox1_SelectedIndexChanged(sender As Object, e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs) Handles Radbox1.SelectedIndexChanged
     
     End Sub
     
     Protected Sub Radbox2_SelectedIndexChanged(sender As Object, e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs) Handles Radbox2.SelectedIndexChanged
     
     End Sub

    When I click on Radbox1 it  trigger both Radbox1 and Radbox2 handler.

    Edit : I tried to put a asp dropdown along with these combo boxes and when I select these combo boxes handler of asp drop down is not triggering which made me think if it is anything to do with telerik handler.

    Edit2: When I tried to set CheckBoxes="false" for Radbox2 then Radbox1 event handler  is only executed . 



    Any Help much appreciated ,

    Thanks,
    Rahul
  2. Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 12 Nov 2012 Link to this post

    Hi Rahul,

    As far as I understand – you want to use the CheckBoxes feature of the RadComboBox.
    In this case you have to handle the ItemChecked event instead of SelectedIndexChanged.
    Please find more details about ItemChecked at this help article.


    Regards,
    Kalina
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. Rahul
    Rahul avatar
    7 posts
    Member since:
    Nov 2012

    Posted 13 Nov 2012 Link to this post

    Hi Kalina,

    Thanks for the reply , ItemChecked will be fine for me if I need to trigger my event handler each time I select an item but in my case I need to trigger event handler once I complete selecting multiple item. Is there anyway we can do that  in ComboBox? .


    Thanks,
    Rahul 
  4. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 13 Nov 2012 Link to this post

    Hi Rahul,

    One suggestion is that you can set a flag in OnClientItemChecked event and trigger postback in OnClientItemChecked event of RadComboBox as follows.

    JS:
    <script type="text/javascript" language="javascript">   
        var flag = false;
        function OnClientBlur(sender, args)
        {
            if (flag)
            {
                __doPostBack("<%= RadComboBox6.ClientID %>", "");
                __doPostBack("<%= RadComboBox7.ClientID %>", "");
            }
        }
        function OnClientItemChecked(sender, args)
        {
            flag = true;
        }
    </script>

    Thanks,
    Shinu.
  5. Rahul
    Rahul avatar
    7 posts
    Member since:
    Nov 2012

    Posted 17 Nov 2012 Link to this post

    Hi Shinu,

    Thank for the reply , actually  found another work around which satisfied my requirement . I checked whether Radcombobox.CheckedItems.Count > 0 then only my required action will be executed and also this will make sure the handler is triggered by right object.

    Thanks again,
    Rahul
  6. Balakrishna
    Balakrishna avatar
    1 posts
    Member since:
    Jan 2017

    Posted 31 Jan in reply to Rahul Link to this post

    Hi Rahul could you please share me the solution 
Back to Top