alex
alex

Reputation: 55

Send data from list to another list then edit in controller

My goal is to transfert data from a list to another. I was able to populates them, and now trying to do the rest. I want to add 2 buttons between the lists so I can send the data from both sides. I need help to code the button, and how to code the controller so I can collect the selected items in the lists (to remove and/or delete).

Here my model :

namespace OnlineTR.WebUI.Areas.Admin.Models { public class TestCategoryModel {

   public IEnumerable<TestCase> TestCasesAvailable { get; set; }
   public IEnumerable<TestCase> TestCasesCurrent { get; set; }

}

}

View :

@model Models.TestCategoryModel           

@Html.ListBoxFor(model => model.TestCasesAvailable, new SelectList(Model.TestCasesAvailable,"TestCaseId", "TestCaseName"))          

@Html.ListBoxFor(model => model.TestCasesCurrent, new SelectList(Model.TestCasesCurrent, "TestCaseId", "TestCaseName"))

Upvotes: 2

Views: 1729

Answers (2)

jim tollan
jim tollan

Reputation: 22485

Alex,

I'd take a look at the jquery UI for the swapping scenarios if that is your use case. I've used a similar technique for a project that required ingredient categories to be added from one list to another. for this, I used jquery draggables and then saved the resultant 'list b' elements as part of a form post (via ajax). These examples may help for starters:

will follow up with more asap

Upvotes: 2

NiK
NiK

Reputation: 1857

Here is an example post...you may try this...it is similar to your problem...

http://www.codeproject.com/Articles/136730/ASP-NET-MVC-2-Basics-Working-with-ListBoxes

Although it is done in MVC 2...that dynamics/approach will still remain the same in MVC 3...

Upvotes: 1

Related Questions