RadListBox OnSelectedIndexChanged JS Error

3 posts, 0 answers
  1. Jeremy
    Jeremy avatar
    29 posts
    Member since:
    Apr 2014

    Posted 05 Aug 2014 Link to this post

    I'm having trouble with the RadListBox on selected index changed. OnSelectedIndexChanged does not fire an event at all and OnClientSelectedIndexChanged gives a JS error.
    I'm using the RadListBoxes to move items around as described in http://demos.telerik.com/aspnet-ajax/listbox/examples/overview/defaultcs.aspx#qsf-demo-source
     
    But I also need to display information about the single selected item so the user knows if this is the right item to move.  But I'm getting a Error: 'AllGroupsRadListBox_SelectedIndexChanged' is undefined.

    <telerik:RadListBox runat="server" ID="AllGroupsRadListBox" Height="200px" Width="200px" AllowTransfer="true" SelectionMode="Single" TransferToID="SharedGroupsRadListBox" OnClientSelectedIndexChanged="AllGroupsRadListBox_SelectedIndexChanged" />
    <telerik:RadListBox runat="server" ID="SharedGroupsRadListBox" Height="200px" Width="200px" /><br />
    Users in selected group:<br />
    <telerik:RadListBox runat="server" ID="UsersRadListBox" Height="200px" Width="200px" />
      
    private void FillAllGroups()
    {
     BWGroups allGroups = new BWGroups();
     allGroups.GetAllBWGroups();
      
     AllGroupsRadListBox.DataTextField = "BWGroupName";
     AllGroupsRadListBox.DataValueField = "BWGroupID";
     AllGroupsRadListBox.DataSource = allGroups.BWGroupList;
     AllGroupsRadListBox.DataBind();
    }
      
    protected void AllGroupsRadListBox_SelectedIndexChanged(object sender, EventArgs e)
    {
    int parseGroupId = -1; Int32.TryParse(AllGroupsRadListBox.SelectedValue.ToString(), out parseGroupId);
    BWUsers usersInGroup = new BWUsers();
      
    if(parseGroupId > 0)
     usersInGroup.GetActiveBWUsersByGroupID(parseGroupId);
      
    UsersRadListBox.DataTextField = "BWGroupName";
    UsersRadListBox.DataValueField = "BWGroupID";
    UsersRadListBox.DataSource = usersInGroup.BWUserList;
    UsersRadListBox.DataBind();
    }
  2. Jeremy
    Jeremy avatar
    29 posts
    Member since:
    Apr 2014

    Posted 05 Aug 2014 Link to this post

    To add another question into the mix.  Once I drag an item from one RadListBox to the TransferTo RadListBox, I want the item I just moved defaulted to selected in the TransferTo RadListBox.  So when I drage a group from AllGroupsRadListBox into SharedGroupsRadListBox, I want the SharedGroupsRadListBox copy of the group to be selected so that the user can then do what he/she needs to do with the Group they just copied without having to then click on it again (my users are very click averse and quite vocal about it).
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 06 Aug 2014 in reply to Jeremy Link to this post

    Hi Jeremy,

    In order to fire the OnSelectedIndexChanged event of RadListBox please try to set the AutoPostBack property of RaListBox to true. The OnClientSelectedIndexChanged event is working fine at my end. Please have a look into the sample code snippet.

    ASPX:

    <telerik:RadListBox runat="server" ID="AllGroupsRadListBox" Height="200px" Width="200px"AutoPostBack="true" AllowTransfer="true" SelectionMode="Single" TransferToID="SharedGroupsRadListBox" OnClientSelectedIndexChanged="changeSelection" OnSelectedIndexChanged="AllGroupsRadListBox_SelectedIndexChanged"/>

    JavaScript:
    function changeSelection(sender, e) {
        alert("fired");
    }

    C#:
    protected void AllGroupsRadListBox_SelectedIndexChanged(object sender, EventArgs e)
    {
        //your code
    }

    As for your second question try to set the TransferMode propert of RadListBox to Copy, it will only copy the items to the destination RadListBox.

    Thanks,
    Shinu.
Back to Top