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

Listbox 'Transfer buttons' are always disabled

3 Answers 123 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
oren yona
Top achievements
Rank 1
oren yona asked on 20 Jul 2010, 08:46 PM
Hi,

I'm trying to simulate the transfer between listbox example
(http://demos.telerik.com/aspnet-ajax-beta/listbox/examples/default/defaultcs.aspx),
but I'm doing it programatically (the listboxes are inside a custom web server control, and are created and populated dynamically).
everything works fine except that the transfer buttons are always disabled, no matter what I try to do.
(I configured one of the list box to "allowTransfer=true" and the "TransferToListoxID" to the other list box's ID)
I even tried the "AllowDrag" option, but when I drag items to the other listbox they just don't get transfered.

What am I doing wrong?

Thanks in advanced!

Oren

3 Answers, 1 is accepted

Sort by
0
Tojara
Top achievements
Rank 1
answered on 21 Jul 2010, 09:09 AM
I've done what you have described several times and I've never encountered such problem. Can you paste here you your codebehind code?
0
oren yona
Top achievements
Rank 1
answered on 21 Jul 2010, 10:36 AM
Sure,
Here's what I've done:

   
public class FilterString : Panel, INamingContainer 
RadWindow window = new RadWindow() {VisibleStatusbar=false, Skin = "Vista", Behaviors = WindowBehaviors.Close | WindowBehaviors.Move, Width = 390, Height = 400 }; 
RadListBox radLstRight = new RadListBox() {AllowTransfer = true, SelectionMode = ListBoxSelectionMode.Multiple, TransferMode = ListBoxTransferMode.Move, Height = 170, Width = 150 ,Skin="Office2007"}; 
RadListBox radLstLeft = new RadListBox() {SelectionMode = ListBoxSelectionMode.Multiple, TransferMode = ListBoxTransferMode.Move, Height = 170, Width = 180, Skin = "Office2007" };

...

public void OpenFilter(DataTable dt, string columnName, string columnNameTran) 
{
    FillStringList(dt, columnName);
    window.VisibleOnPageLoad = true
}
  
protected override void CreateChildControls() 
{
    EnsureChildControls(); 
     ...
    // controls 
    radLstLeft.TransferToID = radLstRight.ID; 
    radLstRight.TransferToID = radLstLeft.ID;
    Table table = new Table() 
     {
        CssClass= "filtermenu_table"
         Rows = { new TableRow() { Cells = { new TableCell() { Controls = { lblHeader } }}}, 
                      new TableRow() { Cells = { new TableCell() { Controls = { radLstRight,radLstLeft}}}}, 
            new TableRow() {Cells = {new TableCell () {Controls = lblSearch, txtSearch,lkbSearch}}}}, 
            new TableRow() {Cells = {new TableCell() { Controls = lkbCut, lkbClose} }}}} 
        };
  
    window.ContentContainer.Controls.Add(table);
    this.Controls.Add(window);
    base.CreateChildControls();
}
  
...
private void FillStringList(DataTable dv, string colName) 
{
    // I Manually Add Items to the listbox, because I want each Item to appear only once 
    (I couldn't do it using databind)
    radLstRight.Items.Clear();
    radLstLeft.Items.Clear();  
    List<string> items = new List<string>(); 
   foreach (DataRow item in dv.Rows) 
    {
    string value = item[colName].ToString(); 
    if (!items.Contains(value)) 
    items.Add(value);
    }
    
    foreach (string item in items) 
       radLstRight.Items.Add(new RadListBoxItem(item));
}

 

NOTE: 'Open filter' is called when a button is clicked on another custom web server control.

 

 

 

 

 

 

 

0
oren yona
Top achievements
Rank 1
answered on 22 Jul 2010, 09:11 AM
Just wanted to say that I solved the problem.
Apparantly I forgot to specify an ID to the listboxes.

everything works now!

thanks,

Oren
Tags
ListBox
Asked by
oren yona
Top achievements
Rank 1
Answers by
Tojara
Top achievements
Rank 1
oren yona
Top achievements
Rank 1
Share this question
or