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.

Manoj
  • 3,947
  • 9
  • 46
  • 84
  • provide code snippets. and if possible, remove explanation which those code snippets already interprets. – Palak Bhansali Mar 23 '15 at 16:28
  • [Have a look here](http://forums.asp.net/t/1900487.aspx?MVC+4+how+to+create+dynamic+controls) doing it by Razor view engine instead js, see if it helps. – Palak Bhansali Mar 23 '15 at 16:32
  • see my answer here, it may give you direction - http://stackoverflow.com/questions/29044104/asp-net-mvc-creating-an-object-with-related-object-in-one-view/29046544#29046544 – vortex Mar 23 '15 at 16:58

0 Answers0