'Supplier'表中的每個記錄都有一個bool'SupplierEmailProvided'列。要顯示在屏幕上的值:取值爲bool並顯示爲複選框
@Model.Suppliers.Where(s => s.Id == products.PreferredSupplierId).FirstOrDefault().SupplierEmailProvided
這工作正常,但ATM它根據其值顯示'真'或'虛假'(在屏幕上)。
我想改變這種狀況到複選框,這將被禁用如果值爲FALSE
想是這樣:@Html.CheckBoxFor(s => s.Suppliers.Where(x => x.SupplierEmailProvided)).FirstOrDefault().SupplierEmailProvided'
反而不好。任何想法傢伙?
編輯 所以我給出了所有建議前。
@if((s => s.Id == products.PreferredSupplierId).FirstOrDefault().SupplierEmailProvided)
{
@Html.CheckBoxFor(s => s.Suppliers
.Where(x => x.Id == products.PreferredSupplierId)
.FirstOrDefault()
.SupplierEmailProvided)
@Html.CheckBox("SupplierEmailProvided",true,
(Model.Suppliers.Where(x => x.SupplierEmailProvided)).FirstOrDefault().SupplierEmailProvided
? (object) new { disabled = "false" } : (object) new {disabled = "true" })
}
如果語句中顯示'operator',則表示開始。不能應用於lamba類型的opperad?
有幫助嗎?
如果supplierEmailProvided爲空,則必須將SupplierEmailProvided.Value – Bearcat9425