title: How to bind to element from collection/list in Blazor?
body: <p>I want to bind values to elements from my list in a loop but I cannot find the good solution.</p>
  <pre><code>&lt;EditForm Model=&quot;@dailyReport&quot; OnValidSubmit=&quot;@SubmitDailyReport&quot;&gt;
          &lt;p&gt;
              &lt;label&gt;Count: &lt;/label&gt;
              &lt;InputNumber min=&quot;1&quot; id=&quot;numberOfEffects&quot; @bind-Value=&quot;numberOfEffects&quot; /&gt;
          &lt;/p&gt;
          @{
              for (int i = 1; i &lt;= numberOfEffects; i++)
              {
                  if (effects.Count &lt; i)
                  {
                      effects.Add(&quot;&quot;);
                  }
  
                  if (effects.Count &gt; i)
                  {
                      effects.RemoveAt(effects.Count - 1);
                  }
  
                  string concatId = &quot;effect&quot; + i.ToString();
  
                  &lt;p&gt;
                      &lt;label for=&quot;@concatId&quot;&gt;@i&lt;/label&gt;
                      &lt;InputText id=&quot;@concatId&quot; @bind-Value=&quot;effects.ElementAt(i-1)&quot; /&gt;
                  &lt;/p&gt;
              }
           }
  //rest code
   &lt;/EditForm&gt;
  </code></pre>
  <p>When I am trying to bind-Value to element from a list I am getting an error:</p>
  <ol>
  <li>error CS0131: The left-hand side of an assignment must be a
  variable, property or indexer error</li>
  <li>error CS1662: Cannot convert lambda
  expression to intended delegate type because some of the return
  types in the block are not implicitly convertible to the delegate
  return type</li>
  </ol>
  <p>I wonder if there is any possible way to bind data to collection. I need it because my Model has a property of type List. In my input form I want to allow adding as many strings as will be needed by the user.</p>
  <h1>edit:</h1>
  <pre><code>@code
  {
      private DailyReport dailyReport = new DailyReport();
      private List&lt;string&gt; effects = new List&lt;string&gt;();
  }
  </code></pre>
  <p>I also tried to do it in foreach loop but another error is showed:
  Cannot assign to 'effect' because it is a 'foreach iteration variable</p>
  <pre><code>foreach (var effect in effects)
              {
                  index++;
                  Console.WriteLine(index);
  
                  string concatId = &quot;effect&quot; + index.ToString();
  
                  &lt;p&gt;
                      &lt;label for=&quot;@concatId&quot;&gt;@index&lt;/label&gt;
                      &lt;InputText id=&quot;@concatId&quot; @bind-Value=&quot;effect&quot; /&gt;
                  &lt;/p&gt;
              }
  </code></pre>