I have a small project that I have started working on in order to learn ASP.net and specifically the razor pages. I have a form to add some data to a list on the page. The issue is that I have not been able to find a way to take the existing model and simply re-display it. My current solution is to simply re-query the data then append the new data to display
ASP form:
<form method="post">
<input type="submit" asp-page-handler="AddData" />
</form>
CodeBehind:
public class IndexModel : PageModel
{
public SampleIndexModel sampleModel;
public void OnPostAddData()
{
sampleModel = new SampleIndexModel();
AddRandomData();
UpdateModel();
}
This works fine for sample data that is not from a database. I would like to avoid going to the database for data that I already have in memory -- so my goal is something like:
public void OnPostAddData(SampleIndexModel currentData)
{
sampleModel = currentData;
AddRandomData();
UpdateData();
}