I am using jquery tablednd plugin
$(document).ready(function () { $('#mygridview').tableDnD(); })
so that my rows in my gridview are draggable. When I dragged a line, I want to call a function in asp.net to preserve the position of the lines. But I canβt find a suitable event in gridview that only responds when a row is clicked.
There is an onDrop method in tableDnd.
$(document).ready(function () { $('#mygridview').tableDnD({ onDrop: function(table, row) { }); })
But how could I call the asp.net method from there? I read some posts about ajax, but I do not understand this.
And I also read about using PageMethods , but it did not call my function.
The question is, how can I write something that updates the table in my database?
UPDATED:
I solved this with the IPostBackEventHandler method.
I had to extend both my user control and my page using IPostBackEventHandler and then added the public void RaisePostBackEvent (string eventArgument) function to both the user control and the page. And finally:
onDrop: function (table, row) { __doPostBack('<%= this.UniqueID %>', 'Select'); }
If someone has a problem with onDrop, you need to give an identifier to each line as follows:
var i = 0; $("#<%= gridviewID.ClientID %>").find('tr').each(function () { $(this).attr('id', i++); });
above the start of tablednd.
Thanks!