public void loadGrid() { string DoctorQuery = @"SELECT [Doctor_ID],[Doctor_Name],[Doctor_Specialist],[Patient_ID] FROM [dbo].[Doctor]"; DoctorGridView.DataSource = db.getData(DoctorQuery); DoctorGridView.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { // Hide database error on page load DataBaseError.Visible = false; // Hide gridview on page load DoctorGridView.Enabled = false; // Redirect to login page if not logged in if (Session[Global.user] == null) { Response.Redirect("Login.aspx"); } // If logged in attempt to pull data from database try { // Bind doctor data to gridview List <Doctor> doctors = DoctorUtility.GetDoctors(); DoctorGridView.DataSource = doctors; DoctorGridView.DataBind(); } // If exception caught show database error // and hide gridview catch (Exception) { DataBaseError.Visible = true; DoctorGridView.Enabled = false; } }
public void PopulateGridview() { DataTable dtbl = new DataTable(); using (SqlConnection sqlCon = new SqlConnection(connectionString)) { string UserQuery = @"SELECT [Doctor_ID],[Doctor_Name],[Doctor_Specialist],[Patient_ID] FROM [dbo].[Doctor]"; sqlCon.Open(); SqlDataAdapter sqlDa = new SqlDataAdapter(UserQuery, sqlCon); sqlDa.Fill(dtbl); } if (dtbl.Rows.Count > 0) { DoctorGridView.DataSource = dtbl; DoctorGridView.DataBind(); } else { dtbl.Rows.Add(dtbl.NewRow()); DoctorGridView.DataSource = dtbl; DoctorGridView.DataBind(); DoctorGridView.Rows[0].Cells.Clear(); DoctorGridView.Rows[0].Cells.Add(new TableCell()); DoctorGridView.Rows[0].Cells[0].ColumnSpan = dtbl.Columns.Count; DoctorGridView.Rows[0].Cells[0].Text = "No Data Found ..!"; DoctorGridView.Rows[0].Cells[0].HorizontalAlign = HorizontalAlign.Center; } }
private void CargarLista() { try { List <Doctores> doctor = DoctorBBL.GetDoctor(); DoctorGridView.DataSource = doctor; DoctorGridView.DataBind(); } catch (Exception ex) { } }
public void loadGrid() { string UserQuery = @"SELECT [Patient_ID],[Patient_Name],[Patient_Mobile],[Patient_Address] FROM [dbo].[Patient]"; string DoctorQuery = @"SELECT [Doctor_ID],[Doctor_Name],[Doctor_Specialist],[Patient_ID] FROM [dbo].[Doctor]"; string MediceneQuery = @"SELECT [medicine_ID],[medicine_Name],[medicine_Price], [Patient_ID] FROM [dbo].[Medicine]"; string PrescriptionQuery = @"SELECT [Pers_ID] ,[Doctor_Name] ,[Date] ,[Patient_Name] ,[Age],[Blood_Pressure],[Pulse_Rate] ,[Patient_Problem] ,[Medicines] ,[Doctor_Advice] ,[Next_Date] FROM [dbo].[Prescription]"; PrescriptionGridView1.DataSource = db.getData(PrescriptionQuery); PrescriptionGridView1.DataBind(); UserGridView.DataSource = db.getData(UserQuery); UserGridView.DataBind(); DoctorGridView.DataSource = db.getData(DoctorQuery); DoctorGridView.DataBind(); MediceneGridView.DataSource = db.getData(MediceneQuery); MediceneGridView.DataBind(); }