Razor Pages - Persisting a SelectList
-
I am struggling to find the best way to persist a select list collection from the OnGet to the OnPost. This is required because I have a razor page with multiple tabs where the user save the details in the first tab (using OnPost that clears the SelectList) and then continues to the next tabs. Repopulating the collection(s) from the database after the post works but that seems like it is the wrong answer.
Never underestimate the power of human stupidity - RAH I'm old. I know stuff - JSOP
-
I am struggling to find the best way to persist a select list collection from the OnGet to the OnPost. This is required because I have a razor page with multiple tabs where the user save the details in the first tab (using OnPost that clears the SelectList) and then continues to the next tabs. Repopulating the collection(s) from the database after the post works but that seems like it is the wrong answer.
Never underestimate the power of human stupidity - RAH I'm old. I know stuff - JSOP
Mycroft Holmes wrote:
Repopulating the collection(s) from the database after the post works but that seems like it is the wrong answer.
Why does it seem like the wrong answer? The only other options would be to store the entire list in one or more hidden fields, which would bloat the request and response sizes; or to store the list in the session, which would increase the memory pressure on the server. If it's possible to reload the list from the database, that seems like the least-bad option.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
Mycroft Holmes wrote:
Repopulating the collection(s) from the database after the post works but that seems like it is the wrong answer.
Why does it seem like the wrong answer? The only other options would be to store the entire list in one or more hidden fields, which would bloat the request and response sizes; or to store the list in the session, which would increase the memory pressure on the server. If it's possible to reload the list from the database, that seems like the least-bad option.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
Interesting, as a desktop developer I have always attempted to reduce the number of calls to the database, caching static tables in memory on the local machine. I was looking for a similar capability in the web development arena. I will have no compunction reloading from the database in future, it will reduce some of the gymnastics I used to perform about current lists!
Never underestimate the power of human stupidity - RAH I'm old. I know stuff - JSOP