Trying to sort repeater rows with this jquery
<p>I am trying to sort repeater rows with this jquery . But I am not able to save  sort items. Please help me . how can save sorting in database as well as in .aspx page?Thank you in advance</p>

<pre><code>&lt;script language="javascript" type="text/javascript"&gt;
$("#defaultList").sortable(); 

$(document).ready(function () {


    $("#defaultList").sortable(

    {
        update: function (ev, ui) {

            var result = $('#defaultList').sortable('toArray');
            updateSequenceNumber(result);
        }

    }


);

});


function updateSequenceNumber(items) {

    var originalIdAndSequenceNumber = '';
    var index = 0;

    for (i = 0; i &lt;= items.length - 1; i++) {

        if (items[i].length == 0)
            continue;

        var item = $('#' + items[i])[0];

        originalIdAndSequenceNumber += item.attributes["originalId"].nodeValue + ":" + index.toString();
        originalIdAndSequenceNumber += "|";
        index = index + 1;
    }

    persistPositionUsingAjax(originalIdAndSequenceNumber);

}

function persistPositionUsingAjax(originalIdAndSequenceNumber) {

    $.ajax(

    {
        type: "POST",
        dataType: "text",
        url: "AjaxService.asmx/UpdateSequenceNumber",
        data: "s=" + originalIdAndSequenceNumber,
        success: function (response) {

        }
    }

    );

}
</code></pre>

<p>my ajax method:</p>

<pre><code>[WebMethod]
public string UpdateSequenceNumber(string s)
{
    s = s.TrimEnd('|');
    string updateQuery = @"update dnn_Table_1 set SortId = {0}
        where ImageId = {1}";
    StringBuilder sb = new StringBuilder();

    string[] originalIdAndSeqNumberArray = s.Split('|');

    foreach (var originalIdAndSeqNumberCombined in originalIdAndSeqNumberArray)
    {
        var tempArray = originalIdAndSeqNumberCombined.Split(':');
        int originalId = Convert.ToInt32(tempArray[0]);
        int sequenceNumber = Convert.ToInt32(tempArray[1]);

        sb.Append(String.Format(updateQuery, sequenceNumber, originalId));
        sb.Append(System.Environment.NewLine);
    }

    UpdateInDatabase(sb.ToString());

    return "Hello World";
}

private void UpdateInDatabase(string updateQuery)
{
    SqlDataProvider sqd = new SqlDataProvider();
    string ConnectionString = sqd.ConnectionString;
    SqlConnection conn = new SqlConnection(ConnectionString);
    SqlCommand command = new SqlCommand(updateQuery, conn);
    command.CommandText = updateQuery;

    conn.Open();
    command.ExecuteNonQuery();

    conn.Close();
}
</code></pre>
