Question about trasnferring items programmatically

6 posts, 1 answers
  1. Manikanta Kiran
    Manikanta Kiran avatar
    10 posts
    Member since:
    Sep 2008

    Posted 21 Dec 2009 Link to this post

    Hi,

    I have two list boxes : available & selected values.

    When I'm allowing edits , I need to pre-populate the available & selected values. So I have tried doing the transfer programmatically :

                radLstAvailable.DataSource = dataList;   
                radLstAvailable.DataTextField = "Name";  
                radLstAvailable.DataValueField = "ID";  
                radLstAvailable.DataBind();  
     
                if (edit)  
                {  
                    List<Steps> steps = DataSvcClient.GetSteps();  
     
                    radLstAvailable.TransferToID = "radLstSelected";  
     
                    foreach (Step step in steps)  
                    {  
                        RadListBoxItem lbItem = radLstAvailable.Items.Where(item => item.Value == step.ID.ToString()).FirstOrDefault();  
     
     
                        if (lbItem != null)  
                        {  
                            if (step.Order == 0)  
                                lbItem.Checked = true;  
                              
                            radLstAvailable.Transfer(lbItem, radLstAvailable, radLstSelected);  
                        }  
                    }  
                } 

    It is transferring the items but not removing them from available values list box. Am I missing something ?

    Please advice.

    Thanks
    Kiran
  2. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1600 posts

    Posted 21 Dec 2009 Link to this post

    Hi Manikanta Kiran,

    Please make sure that you have set the TransferMode of the source RadListBox to Move. Does the issue persist?

    Kind regards,
    Genady Sergeev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Manikanta Kiran
    Manikanta Kiran avatar
    10 posts
    Member since:
    Sep 2008

    Posted 21 Dec 2009 Link to this post

    Genady,

    Thanks,  I tried setting the 'TranserMode' to 'Move'. It did not work.

    Thanks
    Kiran
  4. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1600 posts

    Posted 24 Dec 2009 Link to this post

    Hi Manikanta Kiran,

    I suppose that the ListBox is rebound after you have moved the items. Have you tried to move

    radLstAvailable.DataSource = dataList;  
    radLstAvailable.DataTextField = "Name"
    radLstAvailable.DataValueField = "ID"
    radLstAvailable.DataBind();

    inside the If(edit) conditional statement? I

    I have tried to reproduce the fault in a sample project, unfortunately, no avail. I am attaching my sample project. Can you modify it in a way that reproduces the problem?

    Sincerely yours,
    Genady Sergeev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. Manikanta Kiran
    Manikanta Kiran avatar
    10 posts
    Member since:
    Sep 2008

    Posted 05 Jan 2010 Link to this post

    Thanks. I checked your project and it worked for me as  expected. I dont think the issue is with the listbox transfer method, which you demonstrated with the sample project.

    I used a user control as modal popup for editing items in a rad grid. The user control has the two list boxes. I implemented the XYZ_DataBinding event handler to load the data in the edit pop-up. (Ref :  http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/usercontroleditform/defaultcs.aspx)

    I realized that if  I set the datasource of the listboxes to null in the  DataBinding event handler , the transfer is working as expected. I'm not sure why the datasource needs to be set to null ?

    protected void EmployeeDetails_DataBinding(object sender, System.EventArgs e)  
            {  
                ArrayList tocs = new ArrayList(new string[] { "Dr.", "Mr.", "Mrs.", "Ms." });  
     
                ddlTOC.DataSource = tocs;  
                ddlTOC.DataBind();  
     
                object tocValue = DataBinder.Eval(DataItem, "TitleOfCourtesy");  
     
                if (tocValue == DBNull.Value)  
                {  
                    tocValue = "Mrs.";  
                }  
                ddlTOC.SelectedIndex = tocs.IndexOf((string)tocValue);  
                ddlTOC.DataSource = null;  // WHY DO WE SET THIS TO NULL ?
            }  
     


    Thanks for your help.

    Regards,
    Kiran
  6. Answer
    Genady Sergeev
    Admin
    Genady Sergeev avatar
    1600 posts

    Posted 07 Jan 2010 Link to this post

    Hi Manikanta Kiran,

    This is an issue specific to the RadComboBox and the RadListBox. If the DataSource is not set to null, in a later moment, the Combo/Listbox is going to be rebound. Please, excuse us for this inconvenience.

    All the best,
    Genady Sergeev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top