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
15
votes
1 answer

A Partial View passing a collection using the Html.BeginCollectionItem helper

I made a small project to understand the answer from Stephen Muecke here: Submit same Partial View called multiple times data to controller? Almost everything works. The javascript adds new fields from the Partial View, and I can tell they're bound…
11
votes
1 answer

Using BeginCollectionItem in ASP.net Core

I cannot use BeginCollectionItem by Steve Anderson in asp.net core. I got an error in my partial view when I use @using (Html.BeginCollectionItem("Entries")) { } The type 'HtmlHelper' is defined in an assembly that is not referenced. You must add…
10
votes
1 answer

AccessViolationException was unhandled

I'm attempting to use Steve Sanderson's blog post in order to edit a variable length list in my ASP MVC 3 view. The project builds fine, however whenever the partial view is rendered the program blows up on the using(Html.BeginColletionItem() line…
NealR
  • 10,189
  • 61
  • 159
  • 299
6
votes
5 answers

System.Web.Mvc.HtmlHelper does not contain a definition for

I am trying to use Steve Sanderson's blog post about editing a variable length list. I've installed the dll via the NuGet package manager and made sure that the namespace is in the Views/web.config file. However, I the following error when I attempt…
NealR
  • 10,189
  • 61
  • 159
  • 299
3
votes
2 answers

asp.net core Begin Collection Item core not working with kendo controls

I have used BeginCollectionItem in asp.net core. Inside this collection I have used kendo combobox and datepicker both data not bind with model list when post the data. anyone have idea about it. Below is the code sample for cshtml file @using…
Hitesh Kansagara
  • 3,308
  • 3
  • 17
  • 32
2
votes
1 answer

Using BeginCollectionItem with MVC Core

I don't appear to be having the same issues as most with the implementation of BeginCollectionItem with MVC core, I'm not receiving any of the data. I have this main page that has alot of work on it but here is the javascript that adds new sections…
jcaruso
  • 2,364
  • 1
  • 31
  • 64
2
votes
1 answer

Row & column alignment when dynamically adding rows to a html table using BeginCollectionItem in ASP.NET MVC 3 using jQuery

I have the following html table definition in my main view
StackTrace
  • 9,190
  • 36
  • 114
  • 202
2
votes
1 answer

Nested List of Lists with BeginCollectionItem

I'm using BeginCollectionItem to add items to an inner list of lists. My question is very similar to the following: Nested BeginCollectionItem, however my the object that contains the list is also a list itself (so in the referenced example the tt…
LolBB
  • 55
  • 1
  • 9
2
votes
1 answer

MVC BeginCollectionItem Hidden index
  • I am using BeginCollectionItem HTMLHelper. It works as a charm but it messes up the layout I'm using. BeginCollectionItem renders a
      and
    • to hide it's hidden fields (which contains the unique indexes). So each 'row' you have in your…
    gerb0n
    • 380
    • 1
    • 5
    • 19
    1
    vote
    0 answers

    MVC BeginCollectionItem helper not binding to model instance within view model

    Building a dynamic list in MVC5. Form will post to the controller and I can see the StudentList correctly populated in chrome dev tools but in the controller, the StudentList is empty. Model: public class Student { public int id { get; set; } …
    BattlFrog
    • 3,370
    • 8
    • 56
    • 86
    1
    vote
    1 answer

    MVC BeginCollectionItem Nested List Indexes not working

    I've got a BeginCollectionItem repeater that is working perfectly, however when I try and follow the Joe Stevens blog to add nested lists it doesn't work in the way I expected. I've used the BeginCollectionItemCore as I'm using AspNetCore, I've…
    1
    vote
    1 answer

    MVC BeginCollectionItem

    I'm having some issue getting my partial view BeginCollectionItem to save to the database. I have a form which has a dynamic number of "sections" that can be added to the page, and within each of these fields there is a text box where the user can…
    Lucy Foster
    • 23
    • 1
    • 6
    1
    vote
    1 answer

    Submit data with dynamically added partial view to the controller using ViewModels not working

    I'm adding dynamically items to an Enquiry form. Used partial view to for adding/deleting the items but while submitting the main view the values are not bound. My question is how to do the same. Have checked couple of similar questions here and…
    user2695433
    • 2,013
    • 4
    • 25
    • 44
    1
    vote
    1 answer

    Validation not working when using dynamically created PartialViews mvc5

    I have a View in which Items ( modelview) created/deleted dynamically using BeginCollectionItem and partialview. The dynamically created view's validation is not firing. Code: MainView : @model EnquiryVM @using (Html.BeginForm()) { …
    user2695433
    • 2,013
    • 4
    • 25
    • 44
    1
    vote
    0 answers

    BeginCollectionItem and FluentValidation

    Anyone know if it is possible to use FluentValidation with BeginCollectionItem which appends GUIDs to the field/property names? I was able to set up the validator: RuleForEach(x => x.Insureds).SetValidator(new InsuredInfoValidator()); public class…
    Ryan Buening
    • 1,559
    • 2
    • 22
    • 60
    1
    2 3