I want to pass some data from my view to my controller, my view looks like this:
<div id="Section1" class="divFiles">
<span>Section 1 </span>
<input type="text" name="test[0]">
<input type="text" name="test[1]">
<input type="text" name="test[2]">
<input type="text" name="test[3]">
</div>
<div id="Section2" class="divFiles">
<span>Section 2 </span>
<input type="text" name="test[4]">
<input type="text" name="test[5]">
<input type="text" name="test[6]">
<input type="text" name="test[7]">
</div>
But this way I'm just sending a list of strings to my controller, there are not keys and I need key because I need this to be grouped by keys.
I would like to pass my data like a Dictionary, grouped by sections, for example:
Section 1: {"first string", "second string", "third string"},
Section 2: {"fourth string", "fifth string"}
and like that,I'm thinking that the best way to do this probably is sending the data as a Dictionary of type Dictionary<string, List<string>> where Section 1, Section 2 would be the keys and then the list of string their values, how could I do that? I can use JQuery for that purpose too, but I'm not sure of how I must write the html to send the data like that. Doing it this way my parameter in my controller action should be of type Dictionary<string, List<string>> Any suggestions of doing this in a different way is welcome too