title: How to generate dynamically blazor's @bind-Value?
body: <p>I'm playing with Blazor and I'd like to create a dynamically generated form, which is part of a grid.
  The entity type of the data is passed to the grid and this is the base of the form. The problem I'm facing now is <code>@bind-Value</code>, which is needed to be able to edit the given entity.</p>
  
  <p>I use <a href="https://blazorstrap.io/" rel="nofollow noreferrer">BlazorStrap</a>, and it is a Blazor Server Side project.</p>
  
  <p>I have the following code in the razor file:</p>
  
  <pre><code>@{
  string bind = $"{nameof(_editedItem)}.{propertyInfo.Name}";
  }
  &lt;BSBasicInput InputType="InputType.Text"
                id="@propertyInfo.Name"
                @bind-Value="@bind"/&gt;
  </code></pre>
  
  <p>The problematic part is the last line. Always the <code>_variableName.PropertyName</code> is displayed instead of pulling out the value from the object.</p>
  
  <p>The proper code should look like this:</p>
  
  <pre><code>&lt;BSBasicInput InputType="InputType.Text"
                id="@propertyInfo.Name"
                @bind-Value="_variableName.PropertyName"/&gt;
  </code></pre>
  
  <p>What I tried so far:</p>
  
  <ul>
  <li>multiple flavors of the syntax, but, since I'm not really experienced with Razor syntax, after I while I hit a wall</li>
  <li>debugging shows that the vairable I'd like to edit gets its values, so the problem somewhere the generated <code>@bind-Value</code> value</li>
  <li>I also checked the generated code (the .g files), but I haven't found any smelly there (please, find it below)</li>
  <li>I haven't created yet a POC without dynamically generated forms, because it would take a few hours to create somthing similar complexity.</li>
  </ul>
  
  <p>What is the solution here?</p>
  
  <pre><code>#nullable restore
  #line 24 "/../..ModalEdit.razor"
                                                          bind
  
  #line default
  #line hidden
  #nullable disable
                          , 31, Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this,
  __value =&gt; bind = __value, bind)));
                          __builder4.AddMarkupContent(32, "\n");
  </code></pre>