Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

I want ASP.NET to list a Bool data type, true or false, in the table male if true and female if false

I try to make patients table. I pulled the data from the database with entityframework. But I want to make the gender data male if true then female if false

aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DentistAppointmentSystem.Entity;
namespace DentistAppointmentSystem.AdminPages
{
    public partial class DPatients : System.Web.UI.Page
    {
        DentistAppointmentSystemEntities db = new DentistAppointmentSystemEntities();
        protected void Page_Load(object sender, EventArgs e)
        {
            var hastalar = (from x in db.TBL_PATIENTS
                            select new
                            {
                                x.TBL_USERS.Name,
                                x.TBL_USERS.Surname,
                                x.IDNumber,
                                x.Gender,
                                x.Birthday,
                                x.Phone
                            }).ToList();
            Repeater1.DataSource = hastalar;
            Repeater1.DataBind();

        }
    }
}

table

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I pulled the data from the database with entityframework. But I want to make the gender data male if true then female if false

>Solution :

You can make this change within your anonymous projection.

var hastalar = (from x in db.TBL_PATIENTS
                            select new
                            {
                                x.TBL_USERS.Name,
                                x.TBL_USERS.Surname,
                                x.IDNumber,
                                Gender = x.Gender ? "Male" : "Female",
                                x.Birthday,
                                x.Phone
                            }).ToList();
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading