DEV Community

Discussion on: Add items dynamically in list in .net core

Collapse
 
jstafford5380 profile image
jstafford5380

So, adding the item the first time works but if I try to add another item, it doesn't post back the first item that was added so there's nothing to add to. It's acting as if the form isn't including the new items added in the partial

Collapse
 
stevcooo profile image
Stevan Kostoski

I can't reproduce that, can you check out my repository
github.com/stevcooo/AddItemsDynami...

Collapse
 
jstafford5380 profile image
jstafford5380

Yes will do. I've been working on this exact scenario for a while now and I'm getting really frustrated with the inconsistency in how the model binder works... I think I've gotten to the point where I can consistently add more items, but I'm noticing that the post back of new items appears in the payload but not in the page model. But the page model has the other data and the payload does not.

Collapse
 
jstafford5380 profile image
jstafford5380

Ok I was able to get rid of it. I was using razor pages instead of controllers and I had a javascript bug. So I can add all day long. Can you expand this to add a delete? I'm seeing an issue where the form data doesn't seem to be updating. To reproduce, add two items an keep track of their IDs. Delete the first item and everything seems fine, now add one back, suddenly the first ID is back

Collapse
 
stevcooo profile image
Stevan Kostoski

Thank you for the feedback, I'll check this out, if that's the case on my side too, I'll fix it and I let you know.