Prayag Paneliya
Prayag Paneliya
CC#
Created by Prayag Paneliya on 10/1/2024 in #help
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
6 replies