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

Problem with RadListBox & AjaxManager

10 Answers 273 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Anatoliy
Top achievements
Rank 2
Anatoliy asked on 08 Oct 2012, 07:57 AM
After some action (ComboBoxSelectedItemChange) it throws the Console Error: Source and destination listbox can't be the same.

 I try to fix and understand the problem, but I can't. Please, help as fast as possible!
 
Here is my used telerik components and their properties:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
       <AjaxSettings>
           <telerik:AjaxSetting AjaxControlID="RadListBoxADGroups">
               <UpdatedControls>
                   <telerik:AjaxUpdatedControl ControlID="RadListBoxGroups" />
                   <telerik:AjaxUpdatedControl ControlID="LabelMessage" />
               </UpdatedControls>
           </telerik:AjaxSetting>
           <telerik:AjaxSetting AjaxControlID="RadListBoxGroups">
               <UpdatedControls>
                   <telerik:AjaxUpdatedControl ControlID="LabelMessage" />
               </UpdatedControls>
           </telerik:AjaxSetting>
           <telerik:AjaxSetting AjaxControlID="RadComboBoxPolice">
               <UpdatedControls>
                   <telerik:AjaxUpdatedControl ControlID="RadListBoxGroups" />
               </UpdatedControls>
           </telerik:AjaxSetting>
       </AjaxSettings>
  </telerik:RadAjaxManager>
          <table>
          <tr>
              <td>
                 <telerik:RadListBox ID="RadListBoxADGroups" runat="server" AllowTransfer="True" DataSourceID="ObjectDataSourceADGroup"
                      DataTextField="Name" Height="300px" Width="300px" TransferToID="RadListBoxGroups"
                      EmptyMessage="Active Directory is missing" AutoPostBackOnTransfer="True" OnTransferred="RadListBoxADGroupsTransferred"
                      EnableDragAndDrop="True" TransferMode="Copy">
                      <ButtonSettings TransferButtons="TransferFrom" Position="Right" VerticalAlign="Top"
                          AreaWidth="40" />
                  </telerik:RadListBox>
                  <asp:ObjectDataSource ID="ObjectDataSourceADGroup" runat="server" SelectMethod="SelectADGroups"
                      TypeName="Scheduler.WebClient.ADGroup"></asp:ObjectDataSource>
              </td>
              <td>
               <telerik:RadListBox ID="RadListBoxGroups" runat="server" EmptyMessage="No Sorted Groups"
                      Style="top: 0px; left: 0px; width: 250px; height: 300px" Height="300px" AutoPostBackOnDelete="True"
                      DataKeyField="GroupPoliceId" DataSourceID="ObjectDataSourceFiltGroups" DataTextField="Name"
                      DataValueField="Id" OnDeleted="RadListBoxGroupsDeleted" AllowDelete="True" OnClientDeleting="RadListBoxGroups_Deleting">
                      <ButtonSettings Position="Right" VerticalAlign="Top" AreaWidth="40" />
                  </telerik:RadListBox>
                  <asp:ObjectDataSource ID="ObjectDataSourceFiltGroups" runat="server" SelectMethod="SelectFilteredGroups"
                      TypeName="Scheduler.WebClient.Controller">
                      <SelectParameters>
                          <asp:ControlParameter ControlID="RadComboBoxPolice" Name="politicId" PropertyName="SelectedValue"
                              Type="Int32" />
                          <asp:ControlParameter ControlID="LabelOwnGName" Name="ownGName" PropertyName="Text"
                              Type="String" />
                      </SelectParameters>
                  </asp:ObjectDataSource>
              </td>
          </tr>
          <tr>
              <td>
                  <asp:Label ID="LabelOwnGName" runat="server" />
                  <asp:ObjectDataSource ID="ObjectDataSourceGrPolices" runat="server" SelectMethod="SelectGroupPolices"
                      TypeName="Scheduler.WebClient.Controller"></asp:ObjectDataSource>
              </td>
              <td>
                 <telerik:RadComboBox ID="RadComboBoxPolice" runat="server" DataSourceID="ObjectDataSourceGrPolices"
                      DataTextField="Name" DataValueField="Id" AutoPostBack="True" Width="100px">
                  </telerik:RadComboBox>
              </td>
          </tr>
      </table>
      </div>
  <br />
  <div class="field-center-error">
      <asp:Label ID="LabelMessage" runat="server" ClientIDMode="Static" />
  </div>

It's my RadListBox methods:
protected void RadListBoxADGroupsTransferred(object sender, Telerik.Web.UI.RadListBoxTransferredEventArgs e)
{
   if (e.DestinationListBox != sender)
    {
    foreach (var grpIns in  e.Items.Select(item => new Group { Name = item.Text,
GroupPoliceId = Convert.ToInt32(RadComboBoxPolice.SelectedValue) }) )
        {
          _sc.InsertGroup(grpIns);
        }
        LabelMessage.Text = Controller.Message;
        RadListBoxGroups.DataBind();
    }
}
protected void RadListBoxGroupsDeleted(object sender, Telerik.Web.UI.RadListBoxEventArgs e)
{
  foreach (var grpDel in e.Items.Select(item => new Group { Id = Convert.ToInt32(item.Value),
Name = item.Text }))
    {
      _sc.DeleteGroup(grpDel);
    }
    LabelMessage.Text = Controller.Message;
    RadListBoxGroups.DataBind();
}

10 Answers, 1 is accepted

Sort by
0
Ivana
Telerik team
answered on 10 Oct 2012, 04:27 PM
Hi Anatoliy,

The following online demo demonstrates a case scenario of what you are trying to achieve: http://demos.telerik.com/aspnet-ajax/listbox/examples/functionality/transfer/defaultcs.aspx.

I hope it is helpful.

Regards,
Ivana
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Anatoliy
Top achievements
Rank 2
answered on 11 Oct 2012, 07:24 AM
Hi Ivana,

In that demonstration only Radlist is shown. If you see I have a problem with AjaxManager. It breaks!

Regards,
Anatoliy
the Cinegy team
0
Ivana
Telerik team
answered on 15 Oct 2012, 02:01 PM
Hello Anatoliy,

Try the following configuration of RadAjaxManager.
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="RadListBoxADGroups">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadListBoxGroups" />
            </UpdatedControls>
        </telerik:AjaxSetting>
        <telerik:AjaxSetting AjaxControlID="RadListBoxADGroups">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadListBoxADGroups" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadListBox ID="RadListBoxADGroups" runat="server" AllowTransfer="True" DataSourceID="SqlDataSource1"
    DataTextField="Name" DataValueField="ID" Height="300px" Width="300px" TransferToID="RadListBoxGroups"
    EmptyMessage="Active Directory is missing" AutoPostBackOnTransfer="True" OnTransferred="RadListBoxADGroupsTransferred"
    EnableDragAndDrop="True" TransferMode="Copy">
    <ButtonSettings TransferButtons="TransferFrom" Position="Right" VerticalAlign="Top"
        AreaWidth="40" />
</telerik:RadListBox>
<br />
<telerik:RadListBox ID="RadListBoxGroups" runat="server" EmptyMessage="No Sorted Groups"
    Style="top: 0px; left: 0px; width: 250px; height: 300px" Height="300px" AutoPostBackOnDelete="True">
    <ButtonSettings Position="Right" VerticalAlign="Top" AreaWidth="40" />
</telerik:RadListBox>
You need to make sure the source RadListBox updates itself as well.

Regards,
Ivana
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Anatoliy
Top achievements
Rank 2
answered on 16 Oct 2012, 01:05 PM
Hello Ivana,

I try this configuration and it's not helpful:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
       <AjaxSettings>
           <telerik:AjaxSetting AjaxControlID="RadListBoxADGroups">
               <UpdatedControls>
                   <telerik:AjaxUpdatedControl ControlID="RadListBoxGroups" />
               </UpdatedControls>
           </telerik:AjaxSetting>
           <telerik:AjaxSetting AjaxControlID="RadListBoxADGroups">
               <UpdatedControls>
                   <telerik:AjaxUpdatedControl ControlID="RadListBoxADGroups" />
               </UpdatedControls>
           </telerik:AjaxSetting>
           <telerik:AjaxSetting AjaxControlID="RadListBoxGroups">
               <UpdatedControls>
                   <telerik:AjaxUpdatedControl ControlID="LabelMessage" />
               </UpdatedControls>
           </telerik:AjaxSetting>
           <telerik:AjaxSetting AjaxControlID="RadComboBoxPolice">
               <UpdatedControls>
                   <telerik:AjaxUpdatedControl ControlID="RadListBoxGroups" />
               </UpdatedControls>
           </telerik:AjaxSetting>
       </AjaxSettings>
   </telerik:RadAjaxManager>

I would be appreciative, if you show me an example of complete customization RadAjaxManager for my Components.
0
Ivana
Telerik team
answered on 18 Oct 2012, 03:57 PM
Hello Anatoliy,

Take a look at the attached page. It all works just fine at my end.

Regards,
Ivana
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Anatoliy
Top achievements
Rank 2
answered on 23 Oct 2012, 08:29 AM
Hello Ivana,

I definitely want to find out reason of this problem... So please, Look this Test Project! ADPolices.zip
I hope this will help us to understand the problem. 

If it's possible, explain why the Metro style is "ride" on List-box's attached buttons? 
0
Nencho
Telerik team
answered on 25 Oct 2012, 03:28 PM
Hello Anatoliy,

You should add one additional reference to the UpdatedControls in the AjaxSettings of the AjaxManager. Please keep in mind that each RadListBox should update itself and the other RadListBox control. I have slightly modified the provided sample, in order to show you the correct implementation.
In addition, I have commented the CDN usage in the web.config and I had removed the dll's, in order to reduce the size of the sample. Please find it attached.

Kind regards,
Nencho
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Anatoliy
Top achievements
Rank 2
answered on 29 Oct 2012, 01:52 PM
Hello Nencho ,

Thank you for order of correct implementation of Ajax Settings. But Error still present when I change Selected Combo Box Item and then try to pass AdGroup to second list box. What the reason?

Kind regards,
Anatoliy
0
Nencho
Telerik team
answered on 01 Nov 2012, 09:31 AM
Hi Anatholiy,

Please consider adding one additional reference in the UpdatedControls section for the RadComboBoxPolice, in order to update both RadListBoxes.

Please find the modified sample attached.


Regards,
Nencho
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Anatoliy
Top achievements
Rank 2
answered on 05 Nov 2012, 04:07 PM
Hi Nencho, thank you! It was really helpful!
Tags
ListBox
Asked by
Anatoliy
Top achievements
Rank 2
Answers by
Ivana
Telerik team
Anatoliy
Top achievements
Rank 2
Nencho
Telerik team
Share this question
or