0

I am working in a c# project using MVC framework and Razor for the front view. I am developing a form with dynamic grid which works based on the option selected from the dropdown list. On selecting the option I will generate a dynamic row containing either textbox or checkbox. When the user clicks Add new button I have to show another dropdown list with options. Again based on the option selected another dynamic grid is once again added in the form just below the above steps. So it will be in a situation with row of textboxes and another row with checkboxes. The user can also delete the rows.

To accomplish this, I have tried the following approach in Javascript: I used two tables in that one table will dynamically apend by the dropdown when the user selects a row from the list. In another table has the values of number of textboxes or checkboxes will be appended accordingly based on the dropdown value is selected.

  1. In this approach it continously adds a new row on clicking add new button. But when the dropdown option in row1 is changed then the corresponding checkbox must be replaced with text boxes and vice versa.
  2. And consider I have a row with textboxes and another row with checkboxes. When a checkbox in row2 is checked then the corresponding text box in row1 must be disabled.

In this above approach I have to fix the issues in the 1. and 2. steps. Please let me know is there any better approach other than javascript to implement this logic in C# MVC Razor framework.
Please kindly suggest me the best approach for dynamic grid and also whether javascript is fine to pass the variables to the controller. Thanks in advance.

3
  • provide code snippets. and if possible, remove explanation which those code snippets already interprets. Commented Mar 23, 2015 at 16:28
  • Have a look here doing it by Razor view engine instead js, see if it helps. Commented Mar 23, 2015 at 16:32
  • see my answer here, it may give you direction - stackoverflow.com/questions/29044104/… Commented Mar 23, 2015 at 16:58

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.