Loop through FormCollection with index and key name to get value

310 Views Asked by At

I am trying to loop through a FormCollection where I want to specify the index and key of the formcollection but am not having luck. FormCollection Keys Example

form[0][keyA]
form[0][keyB]
form[0][keyC]
form[1][keyA]
...

And I am trying to loop using but I understand it isn't correct since im running into an error trying to convert from string to an int. Is there an alternative loop I can use to achieve what I need?

       for (int i = 0; i < form.AllKeys.Count(); i++)
        {
            var key1A = form[i]["keyA"]
            var key1B = form[i]["keyB"]
            ....
        }
0

There are 0 best solutions below