Skip to content
Loading
MVC : Binding dynamically added Checkboxes to the Model ???
FieldList class :
  1. public class FieldList  
  2. {  
  3.     public string FieldName { getset;  }  
  4.     public bool Selected { getset; }  
  5. }  
 
 The data received thru json, has a list of fields and I display all those fields as check box. What I want to achieve is - basically, all selected Fields of checkboxes should be saved in Model.RestrictEditFields. And when the user selects that particular table again, all the fields should be displayed and if the value of Selected is true of a FieldList, then that check box should be marked selected.
 
  I am a newbie in MVC and web, I don not get how do I implement this part. What would be the best approach for this ? After researching alot, I could finally add checkboxes dynamically. I am not able to figure out, how and where to bind it with the save & save to the model on clicking Save button. If anyone would help in providing guideline on how to proceed to achieve the goal, would be great.
 
Any help is highly appreciated.
 
Thanks a lot,

2 Replies

Know the answer? Post it — somebody with the same question will find it here.