Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
in my databse there has boolen values so databse it storing as 0 an 1 in list page it coming as true and false i want to display yes for true and no for zero in list page in mvc razr code
@model IEnumerable

@{
    ViewBag.Title = "patientList";
    Layout = "~/Views/Shared/_LayoutPat.cshtml";
}



<p>
    @Html.ActionLink("Create New", "Create")
</p>
<table>
    <tr style="width:200px;">
       
        <th>
            First Name
        </th>
        <th>
           Last Name
        </th>
        <th>
           Insurance
        </th>
        <th>
         Plan name
        </th>
     
        <th>
            Sickness Detail
        </th>
     
        <th>
         Email
        </th>
        <th>
          Phone
        </th>
        <th>
           Address
        </th>
        
        <th>
           Photo
        </th>
        <th>
           City
        </th>
        <th>
           State
        </th>
        <th>
          Country
        </th>
        <th>
         Zip
        </th>
       @* <th>
            @Html.DisplayNameFor(model => model.username)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.password)
        </th>*@
       @* <th></th>*@
    </tr>

@foreach (var item in Model) 
    
    
    
    
    
{
    <tr>
      
        <td>
            @Html.DisplayFor(modelItem => item.Firstname)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Lastname)
        </td>
        <td>
        @item.insurance
           
            
            
           
            
          
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.planname)
        </td>
        
        <td>
            @Html.DisplayFor(modelItem => item.sicknessdetails)
        </td>
        
        <td>
            @Html.DisplayFor(modelItem => item.email)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.telephone)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.address)
        </td>
        
        <td>
            @Html.DisplayFor(modelItem => item.photo)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.city)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.state)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.country)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Zip)
        </td>
     
        <td>
            @Html.ActionLink("Edit", "editpatient", new {  id=item.PID  }) |
            @Html.ActionLink("Details", "detailpatient", new { id=item.PID }) |
            @Html.ActionLink("Delete","delemp", new { id=item.PID })
        </td>
    </tr>
}

</table>
Posted
Updated 12-Nov-13 23:28pm
v2
Comments
♥…ЯҠ…♥ 13-Nov-13 4:45am    
Could you update question your view code?
♥…ЯҠ…♥ 13-Nov-13 5:28am    
Please delete the above comment, i updated your question with your code
sailaja123456 13-Nov-13 5:23am    
in insurance iam getting true and false i need yes and no how to get that

1 solution

Hi Sailaja,

In @item.insurance you are getting true or false....
So in Razor you can code like this
C#
@if (@item.insurance)
{
  //Assign item.insurance with Yes
  <span>Yes</span>
}
else
{
  //Assign item.insurance with No
  <span>No</span>
}

Hope this helps you a bit.

Regards,
RK
 
Share this answer
 
v5
Comments
sailaja123456 13-Nov-13 5:39am    
no in item.insurance im getting True and false it displaying True and False how to get yes or no
sailaja123456 13-Nov-13 5:42am    
How and whre
♥…ЯҠ…♥ 13-Nov-13 5:45am    
update my solution.... just try and lemme know...
sailaja123456 13-Nov-13 7:56am    
No connection string named 'iWaeBetterDoctorsEntities2' could be found in the application config file.wht this error
♥…ЯҠ…♥ 13-Nov-13 8:00am    
you need to post it as separate question.... its ok as of now, connection string name you are trying to access from app.config is missing, just check the name of the connection string in app.config and use it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900