Hello,
I have a manual implementation using asp:ListBoxes and asp:Buttons. It also adds/removes an asp:DropDownList when transferring back and forth from the 2 ListBoxes.
I'm converting it to use RadListBoxes and a RadComboBox. Creating RadListBox1 and RadListBox2 and transferring between the 2 was simple enough. Then I used the OnTransferring Event to invoke a method that will add and remove from RadComboBox1. I have a couple of problems completing this:
- How do I get access in OnTransferring (or other event) to the button selected... To Right(>), To Left(<), All to Right(>>), or All to Left(<<) ?
- In what event, or how... can I invoke a "RemoveFromComboBox" method when selecting/moving back To Left, or All to Left ?
Here's my code:
and code-behind:
I've tested these methods, and they do the job, but I need pass these 4 based on what's selected:
I hope this makes sense and thank you in advance for reviewing this and any assistance.
Ronnie
I have a manual implementation using asp:ListBoxes and asp:Buttons. It also adds/removes an asp:DropDownList when transferring back and forth from the 2 ListBoxes.
I'm converting it to use RadListBoxes and a RadComboBox. Creating RadListBox1 and RadListBox2 and transferring between the 2 was simple enough. Then I used the OnTransferring Event to invoke a method that will add and remove from RadComboBox1. I have a couple of problems completing this:
- How do I get access in OnTransferring (or other event) to the button selected... To Right(>), To Left(<), All to Right(>>), or All to Left(<<) ?
- In what event, or how... can I invoke a "RemoveFromComboBox" method when selecting/moving back To Left, or All to Left ?
Here's my code:
<td><telerik:RadComboBox ID="RadComboBox1" runat="server" /></td> |
<td> |
<telerik:RadListBox ID="RadListBox1" runat="server" Height="200px" Width="200px" |
AllowTransfer="true" TransferToID="RadListBox2" |
AutoPostBackOnTransfer="true" |
SelectionMode="Multiple" EnableDragAndDrop="true" |
OnTransferring="RadListBox1_Transferring" /> |
</td> |
<td> |
<telerik:RadListBox ID="RadListBox2" runat="server" Height="200px" Width="200px" |
AutoPostBackOnTransfer="true" |
SelectionMode="Multiple" EnableDragAndDrop="true" /> |
</td> |
and code-behind:
protected void RadListBox1_Transferring(object sender, RadListBoxTransferringEventArgs e) |
{ |
AddToDefaultComboBox(true); |
RemoveFromDefaultComboBox(true); // Needs to be in different event to return back to left. (maybe RadListBox2_Transferring). But RadListBox2.AllowTransfer="false" ??? find solution. |
} |
// Adds item(s) to RadComboBox1 when transferring from RadListBox1 to RadListBox2 |
private void AddToDefaultComboBox(bool all) |
{ |
foreach (RadListBoxItem li in RadListBox1.Items) |
{ |
if ((li.Selected) || (all)) |
{ |
RadComboBox1.Items.Add(new RadComboBoxItem(li.Text, li.Value)); |
} |
} |
} // Removes item(s) to RadComboBox1 when transferring from RadListBox2 to RadListBox1 |
private void RemoveFromDefaultComboBox(bool all) |
{ |
foreach (RadListBoxItem li in RadListBox2.Items) |
{ |
if ((li.Selected) || (all)) |
{ |
RadComboBox1.Items.Remove(RadComboBox1.Items.FindItemByValue(li.Value)); |
} |
} |
} |
I've tested these methods, and they do the job, but I need pass these 4 based on what's selected:
- AddToDefaultComboBox(false) --> When selecting RadListBox1 item (to right >)
- AddToDefaultComboBox(true) --> When selecting RadListBox1 items (all to right >>)
- RemoveFromDefaultComboBox(false) --> When selecting RadListBox2 item (< to left)
- RemoveFromDefaultComboBox(true) --> When selecting RadListBox2 items (<< all to left)
I hope this makes sense and thank you in advance for reviewing this and any assistance.
Ronnie