I am coding a MVC 5 View, and would like to know how to add data to a hidden 2D array.
Here is my code:
@Html.Hidden("hdnArray")
@for (int i = 0; i < 2; i++)
{
string[] items = new string[4] { "1", "2", "3", "4" };
@Html.HiddenFor(items, { id = "hdnArray" })
}
In the above code, I am trying to add the string[] items
array to the hidden 2D array called hdnArray
.
I am getting many invalid expression errors at the line:
@Html.HiddenFor(items, { id = "hdnArray" })
Can someone please help me with this?
Thanks in advance.