Hey experts, I have this vb.net code that allows me to drag and drop between gridviews that are dynamically produced from the database in a downward direction but will not do that for dragging up. For example, I can drag to department2 from department1 but it will nto let me drag department2 to department1. My aspx page only contains two literal controls as placeholders for the gridview and JQuery produced by the code. Here is my code: - Imports System.Data.SqlClient
-
Imports System.Data
-
-
Partial Class Training_tree_DragDropOrg
-
Inherits System.Web.UI.Page
-
-
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
-
-
If Not IsPostBack Then
-
-
Dim args As New DataSourceSelectArguments
-
Dim dsDivisions As New DataView
-
Dim dsDepartments As New DataView
-
Dim drDivision As DataRow
-
Dim drDepartment As DataRow
-
Dim strDepts As String = ""
-
Dim strLIDepts As String = ""
-
Dim strOLDepts As String = ""
-
SqlDataSourceDivisions.SelectCommand = "Select id, Name from Divisions"
-
dsDivisions = SqlDataSourceDivisions.Select(args)
-
-
If dsDivisions.Table.Rows.Count > 0 Then
-
-
Literal1.Text = ""
-
Dim x As Integer
-
For x = 0 To dsDivisions.Table.Rows.Count - 1
-
drDivision = dsDivisions.Table.Rows(x)
-
Literal1.Text += "<div id='" & drDivision.Item("ame").ToString & "'>"
-
Literal1.Text += "<h1 class='ui-widget-header'>"
-
Literal1.Text += "<h1>" & drDivision.Item("Name").ToString & "</h1>"
-
Literal1.Text += "<div class='ui-widget-content'>"
-
Literal1.Text += "<ol id='list" & drDivision.Item("Name").ToString & "'>"
-
-
SqlDataSourceDepartments.SelectCommand = "Select id, Name from Departments where DivisionID = " & drDivision.Item("id") & " union select ' ', ' '"
-
dsDepartments = SqlDataSourcedepartments.Select(args)
-
-
If dsDepartments.Table.Rows.Count > 0 Then
-
Dim y As Integer
-
Literal1.Text += "<ul id = 'li" & drDivision.Item("Name").ToString & "' class='" & drDivision.Item("id").ToString & "'>"
-
-
For y = 0 To dsDepartments.Table.Rows.Count - 1
-
drDepartment = dsDepartments.Table.Rows(y)
-
Literal1.Text += "<li >" & drDepartment.Item("Name").ToString & "</li>"
-
Next
-
Literal1.Text += "</ul>"
-
-
-
Literal1.Text += "</ol></div>"
-
-
End If
-
-
strDepts += "#" & drDivision.Item("Name") & ","
-
strLIDepts += "#" & drDivision.Item("Name") & ".li ,"
-
strOLDepts += "#list" & drDivision.Item("Name") & ","
-
-
Next
-
-
Literal1.Text += "</div>"
-
strDepts += strDepts.Substring(0, strDepts.Length - 1)
-
strLIDepts += strLIDepts.Substring(0, strLIDepts.Length - 1)
-
strOLDepts += strOLDepts.Substring(0, strOLDepts.Length - 1)
-
-
End If
-
LiteralScript.Text = " <script type='text/javascript'> $(function () {"
-
LiteralScript.Text += " $('" & strLIDepts & "').draggable({appendTo: 'body', helper: 'clone' });"
-
LiteralScript.Text += " $('" & strDepts & "').droppable( { activeClass: 'ui-state-default', hoverClass: 'ui-state-hover',drop: function (event, ui){"
-
LiteralScript.Text += "var selected = $('" & strOLDepts & "').find("":contains('"" + ui.draggable.text() + ""')"");"
-
LiteralScript.Text += " var li = selected[1]; var ol = selected[0]; if(selected.length >0){ ol.removeChild(li); this.appendChild(li);}}}).sortable({items:'li:not(.placeholder)'});"
-
Literal1.Text += "</ol></div>"
-
LiteralScript.Text += " });</script> "
-
-
End If
-
-
End Sub
-
End Class
1 1160
Done a bit more tweaking, this one allows drag up and down but gives me an error. When I drop the item to move, I get this error: - Line: 113
-
Error: Unable to get value of the property 'appendChild': object is null or undefined
Here is the code as it stands now: -
<script type='text/javascript'>$(function () {
-
$('" & strLIDepts & "').draggable();
-
$('" & strOLDepts & "').droppable( { activeClass: 'ui-state-default', hoverClass: 'ui-state-hover' ,drop: function (event, ui){
-
var selected = $('" & strDepts & "').find("":contains('"" + ui.draggable.text() + ""')"");
-
if (selected.length > 0) { var ol = selected[1]; var li = selected[3]; var oldList = ol.children('li' + ol.id); if(oldList){ oldList.removeChild(li);}
-
else{ ol =selected[3]; alert(ol.id); li=selected[4] ; ol.removeChild(li); }}
-
var newItem = document.createElement('li'); var newItemValue = document.createTextNode(ui.draggable.text()); newItem.appendChild(newItemValue); this.children('li' + this.id).appendChild(newItem);
-
}}).sortable({items:'li'});
-
});
-
</script>
-
Sign in to post your reply or Sign up for a free account.
Similar topics
by: simon_s_li |
last post by:
Hi,
I have 5 fields in line where I need to drag and drop the text from one
field to another field and then all the fields need to re-order
themselves.
So for instance if I drag the text in...
|
by: SamSpade |
last post by:
There seems to be two ways to put things on the clipboard ( I don't mean
different formats): SetClipboardData and OleSetClipboard
If I want to get data off the clipboard do I care how it was put...
|
by: Nathan |
last post by:
I'm working for the first time with the DoDragDrop method. I've got almost
everything worked out, but I need some help with the last bit.
There are two listboxes on my form, lstGroups and...
|
by: Kevin L |
last post by:
I have a Panel control that I currently allow the user to drag and
reposition on a form at runtime.
This Panel control contains a Label control.
I would like to allow the user to drag the PANEL...
|
by: Pesso |
last post by:
I'm loading a text file to a RichTextBox control to drag a selection of a
text and drop it into a tree view control. It works except after the drag
and drop operation the RichTextBox scrolls to the...
|
by: Rob |
last post by:
I've searched for info on how to drag and drop a group of strings (or
any other object) from one control to another. Looked through
articles by Dino Esposito, checked the Forms books by Sells and...
|
by: timnels |
last post by:
I have created a muti-select treeview control. Problem is I am now
trying to implement drag/drop in the application that uses it. It
seems the mouse down and mouse move events fire before the...
|
by: bob |
last post by:
Hi all,
I have a treeview that has drag drop.
Works well enough but...
If you drag out of bounds of the treeview the nodrop icon comes on.
Fair enough.
But when I move back inside the treeview...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |