How to use Nested foreach loop inside for loop in Asp.Net MVC
<p>Hello i want to Generate the View Page like this using looping concept,</p>

<pre><code>No CType   PNum
1  Cap     12
2  Bottle  23
</code></pre>

<p>here is my View Page </p>

<pre><code> @for (int i = 1; i &lt; (Enumerable.Count(@ViewBag.TestComponent_ComponentType)); i++)
            {
                foreach (string component_type in ViewBag.TestComponent_ComponentType)
                {
                    foreach (string part_number in ViewBag.TestComponent_ComponentPNumb)
                    {
                        &lt;td&gt;@i) &lt;/td&gt;
                        &lt;td&gt; @Html.Raw(component_type)&lt;/td&gt;
                        &lt;td&gt;(Part #:@Html.Raw(part_number))&lt;/td&gt;
                        i = i + 1;
                    }
                }
            }
</code></pre>

<p>and here is my controller</p>

<pre><code>  ViewBag.TestComponent_ComponentType = context.Test_Component.Where(x =&gt; x.TestRequestId == id).Select(x =&gt; x.ComponentType).ToList();
  ViewBag.TestComponent_ComponentPNumb = context.Test_Component.Where(x =&gt; x.TestRequestId == id).Select(x =&gt; x.PartNumber).ToList();
</code></pre>

<p>please help me.</p>