-
Notifications
You must be signed in to change notification settings - Fork 0
/
departmentreport.aspx.cs
60 lines (52 loc) · 1.75 KB
/
departmentreport.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
49
50
51
52
53
54
55
56
57
58
59
60
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
namespace Internship
{
public partial class departmentreport : System.Web.UI.Page
{
SqlConnection cn;
SqlCommand cm;
SqlDataReader dr;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
display();
}
}
protected void display()
{
string branch = (string)Session["branch"];
string loc = ConfigurationManager.AppSettings["mydb"];
cn = new SqlConnection(loc);
cn.Open();
string queryselect = "select distinct section from internshiptb";
cm = new SqlCommand(queryselect, cn);
// cm.Parameters.AddWithValue("branch1", branch.ToString());
dr = cm.ExecuteReader();
DropDownList1.DataSource = dr;
DropDownList1.DataTextField = "section";
DropDownList1.DataBind();
dr.Close();
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
string loc = ConfigurationManager.AppSettings["mydb"];
cn = new SqlConnection(loc);
cn.Open();
string queryselect = "select * from internshiptb where section=@section1";
cm = new SqlCommand(queryselect, cn);
cm.Parameters.AddWithValue("section1", DropDownList1.Text);
dr = cm.ExecuteReader();
GridView1.DataSource = dr;
GridView1.DataBind();
dr.Close();
}
}
}