Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8054567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:10:44+00:00 2026-06-05T08:10:44+00:00

using the JQuery sortable, and trying to send the new order back to my

  • 0

using the JQuery sortable, and trying to send the new order back to my controller, but not having a whole lot of luck. My view is:

using (Ajax.BeginForm("EditTickerOrder", new AjaxOptions { InsertionMode = InsertionMode.Replace, HttpMethod = "POST", }))
{
    <div id="editableticker">
        @Html.HiddenFor(m => m.ProjectGUID)
        <ul id="sortablediv">
            @foreach (DGI.CoBRA.Tools.BussinessObjects.CollabLibrary.TickerObjects.Ticker t in Model)
            {
                <li class="ui-state-default" id="@t.pKeyGuid.ToString()">
                    <p>@Html.CheckBox(t.pKeyGuid.ToString(), t.Display, new { @class = "activechk" }) 
                        <span style="font-weight: bold">
                            @t.Text
                        </span>
                    </p>
                </li>
            }
        </ul>
    <input type="submit" value="Save New Ticker Order" />
}

and my controller is:

[HttpPost]
public ActionResult EditTickerOrder(Guid ProjectGUID, List<string> items)
{
    TickerCollectionModel TickerData = new TickerCollectionModel();
    TickerData.ProjectGUID = ProjectGUID;
    TickerData.ListAllBySession(ProjectGUID);
    return PartialView("TickerList", TickerData);
}

yet the list<string> items is always null. Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T08:10:45+00:00Added an answer on June 5, 2026 at 8:10 am

    You are writing foreach loops, most definitely violating the naming conventions for your form input fields that the default model binder expects for working with collections. If you don’t respect the established wire format, you cannot expect the default model binder to be able to rehydrate your models in the POST action.

    In fact, why don’t you use view models and editor templates? They make everything trivial in ASP.NET MVC.

    So let’s define a view model that will reflect your view requirements (or at least those shown in your question => you could of course enrich it with additional properties that you want to handle):

    public class TickerViewModel
    {
        public Guid Id { get; set; }
        public bool IsDisplay { get; set; }
        public string Text { get; set; }
    }
    
    public class ProjectViewModel
    {
        public Guid ProjectGUID { get; set; }
        public IEnumerable<TickerViewModel> Tickers { get; set; }
    }
    

    and then a controller whose responsibility is to query your DAL layer, retrieve a domain model, map the domain model into the view model we defined for this view and pass the view model to the view. Inversely, the POST action receives a view model from the view, maps the view model back into some domain model, passes the domain model to your DAL layer for processing and renders some view or redirects to a success action:

    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            // TODO: those values come from a data layer of course
            var model = new ProjectViewModel
            {
                ProjectGUID = Guid.NewGuid(),
                Tickers = new[]
                {
                    new TickerViewModel { Id = Guid.NewGuid(), Text = "ticker 1" },
                    new TickerViewModel { Id = Guid.NewGuid(), Text = "ticker 2" },
                    new TickerViewModel { Id = Guid.NewGuid(), Text = "ticker 3" },
                }
            };
            return View(model);
        }
    
        [HttpPost]
        public ActionResult Index(ProjectViewModel model)
        {
            // Everything will be correctly bound here => map the view model
            // back into your domain model and pass the domain model to 
            // your DAL layer for processing ...
    
            return Content("Thanks for submitting");
        }
    }
    

    a view (it is worth noting that in this example I have used a standard form instead of AJAX but it is trivial to convert it into an AJAX form):

    @model ProjectViewModel
    
    @using (Html.BeginForm())
    {
        @Html.HiddenFor(m => m.ProjectGUID)
        <div id="editableticker">
            <ul id="sortablediv">
                @Html.EditorFor(x => x.Tickers)
            </ul>
        </div>
        <button type="submit">OK</button>
    }
    

    and finally the corresponding editor template which will automatically be rendered for each element of the Tickers collection (~/Views/Home/EditorTemplates/TickerViewModel.cshtml):

    @model TickerViewModel
    
    <li class="ui-state-default">
        <p>
            @Html.CheckBoxFor(x => x.IsDisplay, new { @class = "activechk" }) 
            @Html.LabelFor(x => x.IsDisplay, Model.Text)
            @Html.HiddenFor(x => x.Text)
            @Html.HiddenFor(x => x.Id)
        </p>
    </li>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to follow http://www.foliotek.com/devblog/make-table-rows-sortable-using-jquery-ui-sortable/ And have created a very simple example http://jsfiddle.net/6wbZQ/ It's
I've got 3 UL lists that are using sortable jquery.ui. All works great, but
Since I'm using jQuery UI's sortable extension nestedSortable I'm trying to accomplish to create
We have a sortable list using JQuery UI Sortable that we are trying to
I am new to programming especially jQuery. I am trying to sort (order) images
I am trying to develop a sortable list in Rails 3 using Jquery. I
I'm trying to create a sortable list using the Jquery sortable plugin. I want
I have the following ListView in which I am using the JQuery UI sortable
i am using this jquery to make a drag and drop sortable list. http://jqueryui.com/demos/sortable/
I am using jquery 1.4.2 and trying to achieve the following: 1 - function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.