I think I understand what's the issue.
First off, you want to bind a variable to each of the input text element created dynamically. The easiest way to do so is to define a collection object and bound each element of the collection with an input text element, so that when you, say, click on a button, the event handler for the button is called, perform the calculation, and print the result.
Here's a code sample to do that...copy, run and test:
@for (int i = 0; i < values.Count; i++)
{
var local = i;
<input @bind="@values[local]" type="number" id="f-@i">
}
The sum is: @sum
<button @onclick="Calculate">Calculate</button>
@code{
List<int> values = Enumerable.Range(1, 10).ToList();
int sum = 0;
private void Calculate()
{
sum = 0;
sum = values.Sum();
//for (int i = 0; i < values.Count; i++)
//{
// sum += values[i];
//}
}
}
Now, you can edit the text boxes and press the Calculate button for the new values.
NOTE: I know what is the issue, and why you ask this question... It is related to your previous question. Understand this: You must use a local variable in your for loop...see above. See this also See this also