Reputation: 34158
Im already 5 days trying to make jquery drag and drop with asp.net c# functionality.
I have two asp list view One contains friends list and second one is Group container. All i want to do is when user drags row item from list view and drops on group list view i want write this in sql server data table.
I have made jquery drag and drop its working good and then made asp web service im calling it with javascript and send dragged user`s name.
My web service is static method which of course cannot access to group list view to update it. Then i tried to call my non static method which is getting data from data table and than binds my group`s lit view.
Im calling that function like this
GamerProfile gp = new GamerProfile();
GetClanData();
GamerProfile Is my web form
public partial class GamerProfile : System.Web.UI.Page
GetClanData throws error Object reference not set to an instance of an object.
on this line dlClan.DataSource = _ClandCollection;
I know its happening because i created new class and then called GetClanData();
Does it possible to cal GetClanData without creating new?
Is there any way out?
Can i add row to my list view from javascript? Or make some request which will call GetClanData(non static) method?
If im trying to make this with difficult way please advice easier solution.
Thank. Sorry For my Bad English
this is my whole .js file
function SendUserToC(user) {
var result = PageMethods.AddUserToClan(user, OnSucceeded, OnFailed);
}
function OnSucceeded(result, userContext, methodName) {
if (result.indexOf("Warning") != -1) {
alert(result);
}
}
function OnFailed(error, userContext, methodName) {
}
$(document).ready(function () {
var UserCount = 0;
var UsersList = [];
$(".dragable").draggable({
helper: 'clone',
revert: true,
start: function () {
}
});
$("#clan_drop").droppable({
accept: ".dragable",
drop: function (ev, ui) {
UserCount++;
if (UserCount > 10) {
alert("You cannot add more users. Maximum quantity of gamers in one clan is 10");
} else {
$("#drag_here_container").css("display", "none");
var droppedItem = $(ui.draggable).clone();
$(this).append(droppedItem);
var user = $.trim($(this).find('.friend_user_name').text());
$('.dragable:last').remove();
SendUserToC(user);
}
}
});
});
Upvotes: 2
Views: 1585
Reputation:
And you are sure that _ClandCollection is not null. Right ? If yes, then look into the code that fires up on the setter of the DataSource property of the dlClan object.
Upvotes: 2