Note that there are some explanatory texts on larger screens.

plurals
  1. POExtracting [] elements from form collection - mvc - should use icollection but have mix of types
    primarykey
    data
    text
    <p>have looked at Phil Haacks project on books at </p> <p><a href="http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx" rel="nofollow noreferrer">http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx</a></p> <p>which has been useful, but I have a mix of data types. </p> <p>I use a modelview so that i can have a mix of objects, in this case: Order (ie order.id, order.date etc), Customer, SoilSamplingOrder and a list of SoilSamplingSubJobs which is like this [0].id, [0].field, [1].id, [1].field etc Perhaps I should be using ICollection instead of List? I had problems getting UpdateModel to work so I used an extract from collection method. the first 4 method calls : orderRepository.FindOrder(id); etc give the model the original to be edited. but after this point i'm a little lost in how to update the subjobs. I hope i have delineated enough to make sense of the problem.</p> <pre><code> [HttpPost] public ActionResult Edit(int id, FormCollection collection) { Order order = orderRepository.FindOrder(id); Customer cust = orderRepository.FindCustomer(order.customer_id); IList&lt;SoilSamplingSubJob&gt; sssj = orderRepository.FindSubOrders(id); SoilSamplingOrder sso = orderRepository.FindSoilSampleOrder(id); try { UpdateModel(order, collection.ToValueProvider()); UpdateModel(cust, collection.ToValueProvider()); UpdateModel(sso, collection.ToValueProvider()); IList&lt;SoilSamplingSubJob&gt; sssjs = orderRepository.extractSSSJ(collection); foreach (var sj in sssjs) UpdateModel(sso, collection.ToValueProvider()); orderRepository.Save(); return RedirectToAction("Details", new { id=order.order_id}); } catch { return View(); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload