I have a View which is used to assign priviliges to a user. In the database i created two tables. The name of one table is MainMenuItems and the name of the second table is SubMenu Items. To assign sub menu items to a user i created a view that contains two dropdown lists. The first dropdown list displays the user Codes from the Employees table and the second dropdown list displays the main menu items from the MainMenuItems table. Now i want this view when i select a main menu item from the first DropDown list then all the sub menu items will display from the SubMenuItems table in from of a group of CheckBoxes. So first i will select an Employee Code from the first Dropdown list and select main menu item from the second dropdown list and when i select a main menu item from the second dropdown list then all the sub menu items related to the selected main menu item will display in the form of a group of CheckBoxes and i check one or more sub menu items from the list of check boxes and then press the submit button and this data will store in the database table UsersRightsAssignments. I created the complete view. I also created the checkboxes dynamically using Javascript but now i am confuse how to save the data of this View into the database table becase the first dropdown list has an attribute "asp-for" the second dropdown list contains an attribute "asp-for" but i am creating Checkboxes dynamily and they do not have the "asp-for" attribute so i confuse how can i take the values of all the selected CheckBoxes and store in the database table. Following is my comple code of View:
- class="row">class="col-md-3">class="form-group">
- ="UserCode" class="control-label">Select User Code
- ="UserCode" id="cmbUserCode" class="form-control" asp-items="ViewBag.UserCodes">
class="col-md-3">class="form-group">- ="MainMenuId" class="control-label">Select Main Menu ID
- ="MainMenuId" id="cmbMainMenuID" class="form-control control-size" asp-items="ViewBag.MainMenuIDs">
class="col-md-3">class="form-group">"checkBoxesDiv">@*End of first row*@class="row">class="col-md-3">class="form-group">- "submit" value="Create" class="btn btn-primary" />
How to store the above form data in the database table that contains the following three fields:UserCodeMainMenuIdSubMenuIdThe UserCode and MainMenuId has one to many relation with SubMenuId because for a single UserCode and for a single MainMenuId there is one or more selected values of SubMenuId which is checked from the above list of CheckBoxes.Your help will be highly apprecitres because this is part of my project. Thanks in advancePlease share your code in MVC Core1 Reply
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.

Sivakumar KonetiPosted May 21, 2019, 1:54 AM