views:

8

answers:

1

I have a action result method in the conrtoller which returns a IList to my view. Now the Ilist returns set of rows from database. some of the columns in there are bit values. Now when i am displaying those rows , the bit values are being displayed as true and false. I need to check in a IF condition if the value is true then display Yes , else display no. I am getting an error saying Compiler Error Message: CS0103: The name 'True' does not exist in the current context

<% if(Model.Count < 1)
           {%>
                   No User's Add Under You!
        <% } else {
            foreach (var item in Model) { %> 
           <tr>
           <td class="usertd"><%= Html.Encode(item.UserName) %> </td>
           <td class="usertd"><%= Html.Encode(item.Role) %></td>
           <td class="usertd"><%= Html.Encode(item.Email)%> </td>
           <td><% if (item.EmailDoc.Equals(True)) { %>
               Yes <% } else { %>
               No  <% } %>
           </td>
           <td class="usertd"><%= Html.Encode(item.EmailDoc)%></td>
           <td class="usertd"><%= Html.Encode(item.PrintDoc)%></td>
           <td class="usertd"><%= Html.Encode(item.DownloadDoc)%></td>
           <td class="usertd"><input type="button" value="Edit User"/></td>
           </tr>
            <% }
        } %>
+1  A: 

C# is case sensitive actually:

<% if (item.EmailDoc.Equals(true)) { %>

which of course could be simplified to:

<% if (item.EmailDoc) { %>

But if your item.EmailDoc property is a string you need to do string comparison (it doesn't really make sense in this case to be a string but anyway):

<% if (item.EmailDoc == "True")) { %>
Darin Dimitrov
Thanks, that worked for me
Pinu