Alexander Bank

Alexander Bank

  • NA
  • 17
  • 529

asp-for select selected by database data & post

Jun 5 2018 2:46 AM
Hello friends,
I am new with asp. My project is a small ERP-system with database connection.
 
I have a page which loads data from various Tables and shows it in Inputs and Selects with dropdowns. If I hit the edit button the edit page loads fine an the dropdown fields are loaded from the database. but they are not preselected to the value of the record that is to be edited.
 
1. How to preselect the select field from the actual value of the database record?
2. How to write the value of the select back to database?
 
cshtml.cs file:
 
 
 
cshtml file excerpt with country list loaded from database to a select (works fine):
 
 
excerpt form index page (to the right you see the edit (ändern) button:
 
 
 
excerpt from page as it looks like (Ändern means edit in german):
 
 
 
 Thank you all for your support. Please excuse errors, it is my first question here. I already googled a long time for help on that issue before aksing question here.

Answers (2)