asp.net mvc - take value of bool and display as checkbox -


each record in 'supplier' table has has bool 'supplieremailprovided' column. display value on screen:

@model.suppliers.where(s => s.id == products.preferredsupplierid).firstordefault().supplieremailprovided 

this works fine, atm displays 'true' or 'false' (on screen) depending on value.

i want change checkbox, disabled if value false

tried like:@html.checkboxfor(s => s.suppliers.where(x => x.supplieremailprovided)).firstordefault().supplieremailprovided'

but not good. ideas guys?

edit have given suggestions ago.

@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" })                      } 

the beginning if statment says 'operator '.' cannt applied opperad of type lamba?

any help?

assuming supplieremailprovided boolean type, haven't tested though logic should clear

as have mentioned check box should in disabled state when value false.

@if(model.suppliers.where(x => x.supplieremailprovided)).firstordefault().supplieremailprovided) {      html.checkbox("supplieremailprovided",true) }else {      html.checkbox("supplieremailprovided",false,new{ disabled ="true"} ) } 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -