Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am getting the following error when JQuery Sort calls my sort action:

The parameters dictionary contains an invalid entry for parameter 'DonationIDS' for method 'System.Web.Mvc.EmptyResult SortDonations(System.Collections.Generic.List1[System.Int32])' in 'Vol.Web.Areas.ActivityArea.Controllers.DonationController'. The dictionary contains a value of type 'System.Collections.Generic.List1[Vol.Models.Token]', but the parameter requires a value of type 'System.Collections.Generic.List`1[System.Int32]'.
Parameter name: parameters

jQuery:

$("#dlist").sortable({
        handle: '.sorthandle',
        update: function () {
            var order = $('#dlist').sortable('toArray');
            $.ajax({
                url: '/activity/donation/sortdonations',

                data: { DonationIDS: order },
                type: 'POST',
                traditional: true
            });
        }
    });

Post Values:

Parametersapplication/x-www-form-urlencoded
DonationIDS 1
DonationIDS 8
Source
DonationIDS=1&DonationIDS=8

MVC Action:

 public EmptyResult SortDonations(List<int> DonationIDS)
        {


            int order = 0;
            foreach (int i in DonationIDS)
            {
                donationRepository.UpdateSortOrder(i, order);
                order++;
            }


            return new EmptyResult();
        }

It was working perfectly but now it seems to reference another class, Token. Any ideas what is going on or where to start looking?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
254 views
Welcome To Ask or Share your Answers For Others

1 Answer

enter code hereI changed by action to use a string and it resolved the issue.

     [HttpPost]
        public EmptyResult SortDonations(string[] donationorder)


{

    int order = 0; 
    foreach (var i in donationorder)
    {
        donationRepository.UpdateSortOrder(Convert.ToInt32(i), order);
        order++;
    }


    return new EmptyResult();
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...