Form Data Binding Issue in ASP.NET Core MVC - Dictionary Not Receiving Values

I’m encountering a problem in my ASP.NET Core MVC project when trying to bind form data from dynamically generated checkboxes and text inputs to a dictionary in my view model. Despite selecting checkboxes and entering values, the dictionary in my controller isn't receiving the expected values after form submission. I’m attaching my project files and database script so you can replicate the issue with my actual setup. The goal is to ensure that selected variant items (with checkboxes) and their associated prices are properly inserted into the tbl_product_variants_relation table. Here are the key areas: Razor view: Dynamically generates checkboxes and text inputs based on variants for a selected category. Controller: Receives the form submission but doesn’t capture the selected checkboxes and prices correctly. ViewModel: Contains a dictionary SelectedVariants that should bind the selected variant items and prices. Steps to reproduce: Load the attached project. Restore the database using the provided script. Go to the product form and try selecting variants and entering prices. After submitting the form, check if the selected variant items are inserted into tbl_product_variants_relation. I would appreciate any assistance in resolving this binding issue! i have issue in https://localhost:7179/Product/Add this page to add item check box value store in database https://github.com/prayagpaneliya/myproject
GitHub
GitHub - prayagpaneliya/myproject
Contribute to prayagpaneliya/myproject development by creating an account on GitHub.
4 Replies
Becquerel
Becquerel5w ago
i think a lot of people are going to be hestiant to download and extract .rar files - it would be preferable to upload the repo to github, or the selected files to a gist there do other properties in your viewmodel bind correctly?
Willey
Willey5w ago
I downloaded it, hesitantly 😉 I'm a bit rusty on MVC and EF, but how do these input fields bind to the model:
No description
Willey
Willey5w ago
compared to these:
No description
Prayag Paneliya
GitHub
GitHub - prayagpaneliya/myproject
Contribute to prayagpaneliya/myproject development by creating an account on GitHub.
Want results from more Discord servers?
Add your server