Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Blazor SSR with EditForm, the EditForm model has a list of objects. How can user update a field in one of the objects in the list?

$
0
0

---- SAMPLE Page from AI, NewValue will not update ----------

@page "/test1"

Seq No Employee Name New Value @for (int i = 0; i @formModel.EmpList[i].SeqNo @formModel.EmpList[i].EmpName }
<tr><td>                OutputString = @OutputString</td></tr></tbody></table><button type="submit" class="btn btn-primary">Submit</button>

@code {

public string OutputString = "start";private ModelForm1 formModel = new ModelForm1{    EmpList = new List<ModelEmp>    {        new ModelEmp { SeqNo = 1, EmpName = "Alice" },        new ModelEmp { SeqNo = 2, EmpName = "Bob" },        new ModelEmp { SeqNo = 3, EmpName = "Charlie" }    }};private void HandleValidSubmit(){    foreach (var emp in formModel.EmpList)    {        OutputString += "seqno = " + emp.SeqNo +" NewValue = " + emp.NewValue +" --- ";    }}public class ModelForm1{    public List<ModelEmp> EmpList { get; set; } = new();}public class ModelEmp{    public int SeqNo { get; set; } = 0;    public string EmpName { get; set; } = string.Empty;    public string NewValue { get; set; } = string.Empty;}

}


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>