This is a migrated thread and some comments may be shown as answers.

RadListBack Default selected when transfered

3 Answers 17 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Jeremy
Top achievements
Rank 1
Jeremy asked on 05 Aug 2014, 08:54 PM
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).<telerik:RadListBox runat="server" ID="AllGroupsRadListBox" Height="200px" Width="200px" AllowTransfer="true" SelectionMode="Single" TransferToID="SharedGroupsRadListBox" EnableDragAndDrop="true" 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();
}

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 06 Aug 2014, 07:20 AM
Hi Jeremy,

Please try to attach the OnInserting ‚Äčevent of SharedGroupsRadListBox ‚Äčand there set the each newly inserting item as selected. In order to select more than one Item try to set the SelectionMode of SharedGroupsRadListBox  to Multiple.

ASPX:
<telerik:RadListBox runat="server" ID="SharedGroupsRadListBox" Height="200px" Width="200px"
    SelectionMode="Multiple" OnInserting="SharedGroupsRadListBox_Inserting" />

C#:
protected void SharedGroupsRadListBox_Inserting(object sender, Telerik.Web.UI.RadListBoxInsertingEventArgs e)
{
    foreach (RadListBoxItem item in e.Items)
    {
        item.Selected = true;
    }
}

Thanks,
Princy.
0
Jeremy
Top achievements
Rank 1
answered on 06 Aug 2014, 02:04 PM
Hi Princy,
Thanks for the reply.  I tried what you suggested but I'm not able to get the event to fire.  I've tried both the OnInserting as well as the OnInserted.
<telerik:RadListBox runat="server" ID="SharedGroupsRadListBox" Height="200px" Width="200px"
    AllowTransfer="true" SelectionMode="multiple" EnableDragAndDrop="true"
    TransferToID="AllGroupsRadListBox"
    AutoPostBack="true" OnInserting="SharedGroupsRadListBox_Inserting" OnInserted="SharedGroupsRadListBox_Inserted" />
 
protected void SharedGroupsRadListBox_Inserting(object sender, Telerik.Web.UI.RadListBoxInsertingEventArgs e)
{
    foreach (RadListBoxItem item in e.Items)
    {
        item.Selected = true;
    }
}
 
protected void SharedGroupsRadListBox_Inserted(object sender, RadListBoxEventArgs e)
{
    foreach (RadListBoxItem item in e.Items)
    {
        item.Selected = true;
    }
}


But it's not getting into either method.
0
Jeremy
Top achievements
Rank 1
answered on 06 Aug 2014, 03:01 PM
Found the problem.  Apparently it's not enough to set AutoPostBack="true" but there's also a AutoPostBackOnTransfer that needs to be set.  It's working now.  Thanks for your help Princy.
Tags
ListBox
Asked by
Jeremy
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Jeremy
Top achievements
Rank 1
Share this question
or