-
Notifications
You must be signed in to change notification settings - Fork 1
/
Paper.aspx.cs
75 lines (63 loc) · 1.78 KB
/
Paper.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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;
public partial class Paper : System.Web.UI.Page
{
SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\Database.mdf;Integrated Security=True;User Instance=True");
static Int32 i;
static SqlDataReader dr;
String []ans;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Start_Click(object sender, EventArgs e)
{
Panel1.Visible=true;
Start.Visible = false;
String query;
i = 1;
con.Open();
String query2 = "Select count(Qno) from Qpaper";
SqlCommand cmd2 = new SqlCommand(query2, con);
Int32 n = (Int32) cmd2.ExecuteScalar();
for(Int32 k=1;k<=n;k++)
Qno.Items.Add("Question" + k);
query = "Select * from Qpaper ";
SqlCommand cmd = new SqlCommand(query, con);
dr = cmd.ExecuteReader();
qChange();
}
protected void Next_Click(object sender, EventArgs e)
{
if (i<2)
{
i++;
qChange();
if (dr.HasRows)
Next.Text = "Submit";
}
else if(Next.Text=="Submit")
{
dr.Close();
con.Close();
}
}
void qChange()
{
if (dr.Read())
{
Option.Items.Clear();
Quest.Text = dr.GetString(1);
for (Int32 j = 2; j <= 5; j++)
Option.Items.Add(dr.GetString(j));
}
}
protected void Option_SelectedIndexChanged(object sender, EventArgs e)
{
}
}