-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSchoolV.aspx.cs
48 lines (39 loc) · 1.91 KB
/
SchoolV.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Web.Configuration; //lets us access our webconfig file in C#
namespace CapstoneFinal
{
public partial class SchoolV : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void BtnLoadTeachers(object sender, EventArgs e)
{
String sqlQuery = "Select Name AS School, FirstName + ' ' + LastName AS Teacher, EmailAddress AS Email, grade AS Grade FROM School inner join Teacher ON Teacher.SchoolID = School.SchoolID ";
sqlQuery += " where School.SchoolID = " + ddlSchool.SelectedValue;
SqlConnection sqlConnect = new SqlConnection(WebConfigurationManager.ConnectionStrings["lab4"].ToString());
SqlDataAdapter sqlAdapter = new SqlDataAdapter(sqlQuery, sqlConnect);
DataTable dtForGridView = new DataTable();
sqlAdapter.Fill(dtForGridView);
grdOrderResults.DataSource = dtForGridView;
grdOrderResults.DataBind();
}
protected void BtnShowAll_Click(object sender, EventArgs e)
{
String sqlQuery = "Select Name AS School, FirstName + ' ' + LastName AS Teacher, EmailAddress AS Email, grade AS Grade FROM School inner join Teacher ON Teacher.SchoolID = School.SchoolID ";
SqlConnection sqlConnect = new SqlConnection(WebConfigurationManager.ConnectionStrings["lab4"].ToString());
SqlDataAdapter sqlAdapter = new SqlDataAdapter(sqlQuery, sqlConnect);
DataTable dtForGridView = new DataTable();
sqlAdapter.Fill(dtForGridView);
grdOrderResults.DataSource = dtForGridView;
grdOrderResults.DataBind();
}
}
}