2
Answers

Need a solution for Error in viewpage MVC

Photo of prabhu p

prabhu p

7y
209
1
I am getting error
 
"cannot convert lambda expression to type bool because it is not a delegate type"
 
In mvc view
 
Line
 
@for (int i = 0; i < Model.Count(); i++)
{
<tr>
@if(m => m[i].Selected=="1") //errorline
{
}
<td>
@Html.CheckBoxFor(m => m[i].Selected, new { @checked = "checked" })
</td>
<td>
@Html.DisplayFor(m => m[i].Text)
@Html.HiddenFor(m => m[i].Value)
@Html.HiddenFor(m => m[i].Text)
</td>
</tr>
}

Answers (2)

0
Photo of Dharmraj Thakur
NA 4.1k 61.7k 7y
You have to show me your model and what type is returning from controller. For now you can try it using foreach loop.
  1. @foreach(var item in Model)  
  2. {  
  3.     if(item.Selected == "1")  
  4.     {  
  5.         //stuff          
  6.     }  

0
Photo of Altaf Ansari
NA 1.4k 27.4k 7y
Where you are defining "m" in
 
@if(m => m[i].Selected=="1") //errorline
 
Please define it first before using it..