2011-10-28 5 views
0

私はC#MVC3プロジェクトを持っており、HTML.CheckBoxForの実装に問題があります。私はここで、以下のエラーMVC3 HTML.CheckBoxForエラー

Cannot implicitly convert type 'string' to 'bool' 

を取得していますコードです:

@{ 

List<Domain.LookupCostReductions> costReductions = ViewBag.CostReductions; 
    foreach (Domain.LookupCostReductions cr in costReductions) 
    { 
     @: <td style="border:0 ;vertical-align: top; "> 
     @Html.CheckBoxFor(x => x.CostReduction, cr.Description) 
     @cr.Description 
     @:</td> 
    } 
} 

任意のアイデア?

答えて

2

を試してみてくださいではなくビューに変換し、私はあなたのビューモデルがCostReductionプロパティのブールデータ型を持ってお勧めします。

+0

@ Jared ...ありがとう – MikeTWebb

0

x.CostReductionFieldはbool型である必要があります。

この

@Html.CheckBoxFor(x => Convert.ToBoolean(x.CostReduction), cr.Description) 
関連する問題