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

Unable to transfer single item with listbox inside a tooltip

5 Answers 90 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Larry
Top achievements
Rank 1
Larry asked on 20 Aug 2010, 01:01 PM
Hello,

I'm using two listboxes inside of a tooltip.  The list boxes are configured for single transfer with drag and drop enabled. I am having a problem where I am unable to transfer a single item between the listboxes. Any ideas why this might be happening? I'm using VS2010 and the .NET 4 version of the latest build of Telerik.
Customer.aspx:
  
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="customers.aspx.cs" Inherits="customers" %>
<%@ Register Src="assignusers.ascx" TagName="ProductDetails" TagPrefix="uc1" %>
  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <telerik:RadAjaxLoadingPanel ID="LoadingPanel1" runat="server" Skin="Windows7" />
          
        <telerik:RadAjaxManager ID="AjaxManager1" runat="server" EnablePageHeadUpdate="false">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadGrid1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1"/>
                        <telerik:AjaxUpdatedControl ControlID="Literal1" />
                        <telerik:AjaxUpdatedControl ControlID="RadToolTipManager1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
  
        <telerik:RadToolTipManager ID="RadToolTipManager1" OffsetY="-1" HideEvent="ManualClose"
            Width="620" Height="230" runat="server" EnableShadow="true" OnAjaxUpdate="OnAjaxUpdate"
            RelativeTo="Element" Position="MiddleRight" Modal="true">
        </telerik:RadToolTipManager>
  
        <asp:Literal ID="Literal1" runat="server" Text="" />
        <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" DataSourceID="EntityDataSource1"
             AllowAutomaticInserts="true" AllowAutomaticUpdates="true" AllowAutomaticDeletes="true" AllowPaging="true" PageSize="10"
             EnableLinqExpressions="false" OnItemCommand="RadGrid1_ItemCommand" OnItemDataBound="RadGrid1_ItemDataBound">
             <MasterTableView DataKeyNames="id" CommandItemDisplay="Top" EditMode="PopUp">
                 <EditFormSettings CaptionFormatString="Add/Edit Customers" PopUpSettings-Modal="true"
                     EditFormType="WebUserControl" UserControlName="editcustomer.ascx" PopUpSettings-Width="700px">
                 </EditFormSettings>
                 <Columns>
                    <telerik:GridButtonColumn ButtonType="LinkButton" Text="edit" CommandName="Edit" />
                    <telerik:GridButtonColumn ButtonType="LinkButton" Text="delete" CommandName="Delete" />
                    <telerik:GridBoundColumn DataField="name" HeaderText="Name" />
                    <telerik:GridTemplateColumn UniqueName="AssignUsers">
                        <ItemTemplate>
                            <asp:HyperLink ID="targetControl" runat="server" NavigateUrl="#" Text="Assign Users" />
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                </Columns>
             </MasterTableView>
        </telerik:RadGrid>
    </div>
    <asp:EntityDataSource ID="EntityDataSource1" runat="server" 
        ConnectionString="name=EntityFrameworkTestEntities" 
        DefaultContainerName="EntityFrameworkTestEntities" EnableDelete="True" 
        EnableFlattening="False" EnableInsert="True" EnableUpdate="True" 
        EntitySetName="Customers" Include="Users" OnDeleted="EntityDataSource1_Deleted"
        OnInserting="EntityDataSource1_Inserting" OnUpdating="EntityDataSource1_Updating"
        OnInserted="EntityDataSource1_Inserted" OnUpdated="EntityDataSource1_Updated"
        ViewStateMode="Enabled">
    </asp:EntityDataSource>
    </form>
</body>
</html>
  
assignusers.ascx:
  
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="assignusers.ascx.cs" Inherits="assignusers" %>
<%@ Import Namespace="Telerik.Web.UI" %>
<div>
    <table>
        <tr>
            <td>Users <b>NOT</b> Assigned To This Customer</td>
            <td>Users Assigned To This Customer</td>
        </tr>
        <tr>
            <td>
                <telerik:RadListBox ID="RadListBox1" runat="server" Width="300px" Height="200px" AutoPostBack="false"
                    SelectionMode="Single" AllowTransfer="true" TransferToID="RadListBox2" AutoPostBackOnTransfer="true"
                    EnableDragAndDrop="true" AllowReorder="false">
                </telerik:RadListBox>
            </td>
            <td>
                <telerik:RadListBox ID="RadListBox2" runat="server" Width="300px" Height="200px" AutoPostBack="false"
                    SelectionMode="Single" AllowReorder="false" EnableDragAndDrop="true" AutoPostBackOnTransfer="true" 
                    AllowTransfer="true" TransferToID="RadListBox1"
                    OnDeleting="RadListBox2_Deleting" OnInserting="RadListBox2_Inserting">
                </telerik:RadListBox>
            </td>
        </tr>
    </table>
</div>
  
assignusers.ascx.cs:
  
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections.Specialized;
using Telerik.Web.UI;
  
public partial class assignusers : System.Web.UI.UserControl
{
    public int Id
    {
        get { return Convert.ToInt32(ViewState["id"]); }
        set { ViewState["id"] = value.ToString(); }
    }
  
  
    protected void Page_Load(object sender, EventArgs e)
    {
        RadListBox1.Items.Clear();
        RadListBox2.Items.Clear();
        using (var context = new EntityFrameworkTestModel.EntityFrameworkTestEntities())
        {
            if (RadListBox2.DataSource == null)
            {
  
                var customer = context.Customers.First(p => p.id == Id);
                RadListBox2.DataSource = customer.Users.ToList();
                RadListBox2.DataKeyField = "id";
                RadListBox2.DataTextField = "name";
                RadListBox2.DataValueField = "id";
                RadListBox2.DataBind();
            }
  
            if (RadListBox1.Items.Count == 0)
            {
                var users = from u in context.Users
                            orderby u.name
                            select u;
                foreach (var user in users)
                {
                    if (RadListBox2.FindItemByValue(user.id.ToString()) == null)
                    {
                        RadListBoxItem _item = new RadListBoxItem(user.name, user.id.ToString());
                        RadListBox1.Items.Add(_item);
                    }
                }
            }
        }
    }
  
    protected void RadListBox2_Deleting(object sender, RadListBoxDeletingEventArgs e)
    {
        using (var context = new EntityFrameworkTestModel.EntityFrameworkTestEntities())
        {
            var customer = context.Customers.First(p => p.id == Id);
            foreach (RadListBoxItem item in e.Items)
            {
                int _itemid = Convert.ToInt32(item.Value);
                var user = context.Users.First(u => u.id == _itemid);
                customer.Users.Remove(user);
            }
            context.SaveChanges();
        }
    }
  
    protected void RadListBox2_Inserting(object sender, RadListBoxInsertingEventArgs e)
    {
        using (var context = new EntityFrameworkTestModel.EntityFrameworkTestEntities())
        {
            var customer = context.Customers.First(p => p.id == Id);
            foreach (RadListBoxItem item in e.Items)
            {
                int _itemid = Convert.ToInt32(item.Value);
                var user = context.Users.First(u => u.id == _itemid);
                customer.Users.Add(user);
            }
            context.SaveChanges();
        }
    }
}

Thanks in advance.
Larry

5 Answers, 1 is accepted

Sort by
0
Larry
Top achievements
Rank 1
answered on 27 Aug 2010, 07:14 PM
Does anyone have any ideas about this?
0
Genady Sergeev
Telerik team
answered on 30 Aug 2010, 05:07 PM
Hello Larry,

Does the transfer fail when using Drag and Drop or when transferring using Drag and Drop. Also, which version of Telerik Ajax Controls do you use?

All the best,
Genady Sergeev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Larry
Top achievements
Rank 1
answered on 30 Aug 2010, 05:16 PM
Hey Genady,

I'm using Fileversion 2010, 2, 713, 40

I cannot drag and drop a single item from one list box to the other nor can I use the transfer single item arrow. The screen just flashes and nothing changes.  The OnDeleting and OnInserting events don't seem to fire either.

0
Genady Sergeev
Telerik team
answered on 08 Sep 2010, 09:33 AM
Hello Larry,

I was not able to reproduce the problem in a sample project. I suppose the problem is something specific of your project. I suggest that you open a support ticket and attach sample runnable project that reproduces the problem that you are facing. This will allow us to  trobouleshoot the issue.  Just for reference I am attaching my sample project to this replay. Can you reproduce the problem on it?

Greetings,
Genady Sergeev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Larry
Top achievements
Rank 1
answered on 26 Sep 2010, 07:24 PM
Hey Genady,

It was Page_Load logic.  It kept initializing my listboxes. All works.

Thanks,
Larry
Tags
ListBox
Asked by
Larry
Top achievements
Rank 1
Answers by
Larry
Top achievements
Rank 1
Genady Sergeev
Telerik team
Share this question
or