Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

how to update a record with optional items

$
0
0

Hello.

I have a table in db:

Id, title, imageurl

In add view I get IFormFile for image url and get the relative path and save image url it is ok but in edit view I want to edit this record and I want to save new image url if user select a new image or save old imageurl if user leave image blank.

If I use db.ImagesTable.Update(myviewmodel);

If user does not select a new image it will fill the imageurl with null value.

Can anyone help me to know how can I set this field required in add view and optional in edit view that if user does not select image in edit view automatically fill this field with old value?


Viewing all articles
Browse latest Browse all 9386

Trending Articles



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