-
Notifications
You must be signed in to change notification settings - Fork 0
/
PracticeResult.aspx.cs
47 lines (38 loc) · 1.22 KB
/
PracticeResult.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
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.Data;
public partial class PracticeResult : System.Web.UI.Page
{
String sub, score;
int right_ans = 0,ts;
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ToString());
SqlDataReader rd;
protected void Page_Load(object sender, EventArgs e)
{
SqlDataAdapter da1 = new SqlDataAdapter("SELECT Opt_Selected,Ans FROM Answer", con);
DataTable dt1 = new DataTable();
da1.Fill(dt1);
int i = 0;
foreach (DataRow dr in dt1.Rows)
{
if (dt1.Rows[i]["Opt_Selected"].ToString() == dt1.Rows[i]["Ans"].ToString())
{
right_ans++;
}
i++;
}
Label1.Text = right_ans.ToString();
Label2.Text = Session["Subject"].ToString();
sub = Session["Subject"].ToString();
}
protected void Button1_Click(object sender, EventArgs e)
{
Session["Subject"] = sub;
Response.Redirect("PracticeViewResult.aspx");
}
}