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

How to fetch the listbox records in server side in c#

1 Answer 89 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Raj
Top achievements
Rank 1
Raj asked on 09 Mar 2016, 05:25 AM

hi all,

 

my scenario:

i have three listbox, EmployeeName as Parent List Box, ProjectAdmin and ProjectReader as Child List box. i will drag and drop from parent list to its child list box. the drag and drop concept is working fine for me(i doing this in client side using Javascript). while i am inserting the details in database in c#, the Child list box shows empty. i cannot fetch the items in c# server, where the drag and drop done in javascript.

HTML Code

<table class="normal_grid">
                <tr>
                    <th style="width: 17%">
                        <asp:Label ID="lblemployeename" runat="server" Text="Employee Name"></asp:Label>
                    </th>
                    <td class="field" style="width: 17%">
                        <telerik:RadListBox runat="server" ID="rlbemployeename" EnableDragAndDrop="true"
                            Width="150px" Height="150px" OnClientDropped="lbemployeenamedropped">
                        </telerik:RadListBox>
                    </td>
                    <th style="width: 16%">
                        <asp:Label ID="Label1" runat="server" Text="Project Admin"></asp:Label><span class="hlt_txt">*</span>
                    </th>
                    <td class="field" style="width: 17%">
                        <telerik:RadListBox runat="server" ID="rlbadminname" EnableDragAndDrop="true" Width="150px"
                            Height="150px" OnClientDropped="lbadminnamedropped">
                        </telerik:RadListBox>
                    </td>
                    <th style="width: 16%">
                        <asp:Label ID="Label2" runat="server" Text="Project Reader"></asp:Label><span class="hlt_txt">*</span>
                    </th>
                    <td class="field" style="width: 17%">
                        <telerik:RadListBox runat="server" ID="rlbreadername" EnableDragAndDrop="true" Width="150px"
                            Height="150px" OnClientDropped="lbreadernamedropped">
                        </telerik:RadListBox>
                    </td>
                </tr>
            </table>

 

Javascript Code:

function lbemployeenamedropped(sender, args) {
                transferManager.performTransfer(sender, args);
            }
 
            function lbadminnamedropped(sender, args) {
                transferManager.performTransfer(sender, args);
            }
 
            function lbreadernamedropped(sender, args) {
                transferManager.performTransfer(sender, args);
            }
 
            (function ($) {
                transferManager = function () { }
                debugger;
                transferManager.performTransfer = function (sender, args) {
                    var destinationItemIndex = this._getDestinationIndex(args);
                    var destinationListBox = this._getDestinationListBox(args);
 
                    if (destinationListBox == null)
                        return;
 
                    var reorderIndex = args.get_dropPosition() == 0 ?
                destinationItemIndex : destinationItemIndex + 1;
 
                    var items = args.get_sourceItems();
 
                    this._transfer(items, destinationListBox, reorderIndex);
                }
 
                transferManager._transfer = function (items, destination, reorderIndex) {
                    $.each(items, function (index, item) {
                        item.unselect();
                        destination.get_items().insert(reorderIndex, item);
                    });
                }
 
                transferManager._getDestinationIndex = function (args) {
                    var destinationItem = args.get_destinationItem();
                    if (destinationItem)
                        return destinationItem.get_index();
                    return 0;
                }
 
                transferManager._getDestinationListBox = function (args) {
                    var destinationItem = args.get_destinationItem();
                     
                    if (destinationItem) {
                        var id = destinationItem.get_listBox().get_id();
                        return $find(id);
                    }
 
                    var parent = $(args.get_htmlElement()).parent();
                    if (parent.is(".RadListBox")) {
                        var id = parent[0].id;
                        return $find(id);
                    }
                    else if (parent.is(".rlbGroup")) {
                        var id = parent[0].parentNode.id;
                        return $find(id);
                         
                    }
                }
            })($telerik.$);

 

anything wrong in this code.

Tanks in Advance

ASRK.....

 

1 Answer, 1 is accepted

Sort by
0
Raj
Top achievements
Rank 1
answered on 09 Mar 2016, 06:15 AM

THANKS TO ALL

 

got solution.

Tags
General Discussions
Asked by
Raj
Top achievements
Rank 1
Answers by
Raj
Top achievements
Rank 1
Share this question
or