Questions tagged [begincollectionitem]

A handy HtmlHelper that was originally authored by Steve Sanderson. It's based on the MVC2 style of converting HTTP POST data into ViewModel collection properties using the out of the box DefaultModelBinder, and is quite helpful when your HTML forms contain collections.

This is a handy HtmlHelper that was originally authored by Steve Sanderson. It's based on the MVC2 style of converting HTTP POST data into ViewModel collection properties using the out of the box DefaultModelBinder, and is quite helpful when your HTML forms contain collections.

This class is in the HtmlHelpers.BeginCollectionItem namespace. To use it in a view you would either put a @using HtmlHelpers.BeginCollectionItem directive at the top of the view, or to make it available to multiple views, add an entry in the system.web.webPages.razor/pages/namespaces section of your Views web.config(s). When installing this into an MVC3 or higher project, the second option is done automatically for your root Views/Web.config file:

37 questions
1
vote
0 answers

Why do I get random null items in a collection after model binding?

I'm using the package BeginCollectionItem for ASP MVC. I have a form to create and entity, which has an ICollection property. That property needs to be populated with items dinamically within the form. This is how the DTO looks: public class…
Hernan Demczuk
  • 395
  • 1
  • 3
  • 11
1
vote
3 answers

Show/Hide Logic with BeginCollectionItem

I'm using BeginCollectionItem and I'm trying to figure out how to get each individual collection value to do conditional show/hide logic. For example, if I have the following razor markup:
@using…
Ryan Buening
  • 1,559
  • 2
  • 22
  • 60
1
vote
0 answers

MVC 5 - Registering JavaScript events from partial view which uses BeginCollectionItem

I have a partial view which looks like this: @model Whatever.Models.Jobs @using (Html.BeginCollectionItem("JobRecords")) { @Html.HiddenFor(m => m.Id) @Html.EditorFor(m => m.Project,…
px06
  • 2,256
  • 1
  • 27
  • 47
1
vote
0 answers

Couldn't bind properly from view to model using BeginCollectionItem with nested collection

I am following this blog Editing a variable length list, ASP.NET MVC 2-style by Steven Anderson and started using Html.BeginCollectionItem() for my ASP.NET MVC project. The project is about associating multiple permissions to roles. It will have a…
1
vote
0 answers

Why HtmlHelpers.BeginCollectionItem add guid to my items?

Functionality: i want to update viewModel from jquery each time user choose to update PersonList on the view. So if i have a class person : public class Person { public string Name {get;set;} public int Age {get;set;} } And i have a complex…
0
votes
0 answers

How do I get the values of a BeginCollectionItem in javascript

I want to get values of a BeginCollectionItem using javascript but it seems like i am not winning my html @using HtmlHelpers.BeginCollectionItemCore @using E_Commerce.Application.Models @model ProductImageModel
  • 0
    votes
    1 answer

    Clicking Delete button redirects to Loging page

    I am using BeginCollectionItem to dynamically add items to a list. If I attempt click a newly added row, the app immediately halts and redirects me to the login page. If I delete an item that already existed, it deletes it from the database, then…
    Rani Radcliff
    • 4,856
    • 5
    • 33
    • 60
    0
    votes
    0 answers

    Div is Not Removed with jQuery after ajax POST to MVC Controller

    I am using BeginCollectionItem to dynamically add items (in this case, Comments) to a list. In attempting to "remove" an item I have run into an issue. I can remove an 'existing' item from the UI using jQuery without issue using the following…
    Rani Radcliff
    • 4,856
    • 5
    • 33
    • 60
    0
    votes
    1 answer

    HTM BeginCollectionItem returns only first item of collection

    I have the following problem: A collection of "Gifts" gets passed as a parameter to a view. Each item inside this collection is a object from the Model class "Gift". There are only two properties inside this class: name and price. I put the class…
    P.Sienaert
    • 11
    • 3
    0
    votes
    2 answers

    How do I get HTML form data in Partial View to be serialized when parent view has same model?

    I have a view that contains several partial views with different models, all except one, which has the same model as the parent view. The reason being, parent view represents a Risk, and the partial view is loaded based on whether the Risk is…
    0
    votes
    1 answer

    Map GET request to Action

    I'm trying to validate the progress quantity (and other fields once this works) that belongs to the BeginCollectionItems server side. The request is being sent but the parameter progressQty is not being read by the action. This is the action I'm…
    0
    votes
    0 answers

    Using BeginCollectionItem for adding/deleting Lineitems in MVC5 partialview

    I'm trying to add/delete EnquiryLineItems into Quotation View. Tried to follow MVC 5 Dynamic Rows with BeginCollectionItem BeginCollectionItem partial within partial not behaving correctly MVC 5 BeginCollectionItem with Partial CRUD But while…
    0
    votes
    0 answers

    MVC Ajax call not populating "BeginCollectionItem" string correctly

    I have a PartialView that is working properly when called like this:
    @foreach (FormEmailMessageEmailAddress toRecipient in Model.ToRecipients) { …
    Derek
    • 653
    • 7
    • 20
    0
    votes
    1 answer

    MVC Remote validation is adding model to url

    I have remote validation on a field and it fires but I get a 500 error saying the parameter is null at the controller method is null. What is actually happening is the model name is added to the url, which makes it unable to find the…
    BattlFrog
    • 3,370
    • 8
    • 56
    • 86
    0
    votes
    1 answer

    ASP.NET MVC + Retrieving one to many relationship using jQuery Tab

    I have a form that has a section where it uses jQuery tab generated by BeginCollectionItem. This is done by one-to-many relationship. I can create multiple tabs within the form and can submit it (newForm.cshtml). However, when it comes to editing,…
    bbusdriver
    • 1,577
    • 3
    • 26
    • 58