I have CreateForm
action in ProductController. This action uses view with model: ProductSupplierViewModel
(consists of Product and List<Supplier> Suppliers).
In my CSHTML i have
@Html.LabelFor(m => m.Product.Supplier)
@Html.DropDownListFor(m => m.Product.Supplier.Id, new SelectList(Model.Suppliers, "Id", "Name"), "", new { @class = "form-control" })
BUT, this way i only have my default option set to blank (by using two quotation makrs in html helper).
What i need to know is:
- how to set a
value="0"
to that blank option? - Does the web have default value if we dont specify one for it or?
Trying to get 0 because in my DataAccessLayer i have CreateProduct(Product p)
method where i'll specify:
if(p.Supplier.Id == 0) // from parameter
{
*put NULL value in this DB field*
}