protected void Page_Load(object sender, EventArgs e) { Page.DataBind(); if (!IsPostBack) { userId = (int)Session["userId"]; user = dc.getContactDetails(userId); eContactC = user.eContact; nameC = user.name; addressC = user.address; medicalIdC = user.medicalId; medical = dc.getMedicalDetails(userId); allergiesC = medical.allergies; bloodGroupC = medical.bloodGroup; specialConditionC = medical.specialCondition; hs = dc.getHospitalDetails(); } }
public Medical getMedicalDetails(int u) { Medical medical = new Medical(); cmd = new SqlCommand("select allergies,bloodGroup,specialCondition from medicalData WHERE userId=@userId", con); cmd.Parameters.AddWithValue("@userId", u); con.Open(); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { medical.allergies = dr["allergies"].ToString(); medical.bloodGroup = dr["bloodGroup"].ToString(); medical.specialCondition = dr["specialCondition"].ToString(); } dr.Close(); con.Close(); return medical; }