温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:多功能在线考试系统源码
当前文件:
OnLineExam/Web/TestAnswer.aspx.cs,打开代码结构图
OnLineExam/Web/TestAnswer.aspx.cs,打开代码结构图1using System; 2
using System.Data; 3
using System.Configuration; 4
using System.Collections; 5
using System.Web; 6
using System.Web.Security; 7
using System.Web.UI; 8
using System.Web.UI.WebControls; 9
using System.Web.UI.WebControls.WebParts; 10
using System.Web.UI.HtmlControls; 11
using MyOnLineExam.DataAccessLayer; 12
using System.Data.SqlClient; 13
using MyOnLineExam.BusinessLogicLayer; 14
15
public partial class Web_TestAnswer : System.Web.UI.Page 16
{ 17
protected void Page_Load(object sender, EventArgs e) 18
{ 19
if (!IsPostBack) 20
{ 21
lblPaperName.Text = Session["PaperName"].ToString(); 22
InitData(); 23
} 24
} 25
//初始化试卷,从数据库中将试题取出 26
protected void InitData() 27
{ 28
SqlParameter[] Params1 = new SqlParameter[2]; 29
DataBase DB = new DataBase(); 30
int paperID = int.Parse(Session["PaperID"].ToString()); 31
Params1[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperID); //试卷编号 32
Params1[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "单选题"); //题目类型 33
DataSet ds1 = DB.GetDataSet("Proc_PaperDetail", Params1); 34
GridView1.DataSource = ds1; 35
GridView1.DataBind(); 36
((Label)GridView1.HeaderRow.FindControl("Label27")).Text = ((Label)GridView1.Rows[0].FindControl("Label4")).Text; 37
38
SqlParameter[] Params2 = new SqlParameter[2]; 39
Params2[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperID); //试卷编号 40
Params2[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "多选题"); //题目类型 41
DataSet ds2 = DB.GetDataSet("Proc_PaperDetail", Params2); 42
GridView2.DataSource = ds2; 43
GridView2.DataBind(); 44
((Label)GridView2.HeaderRow.FindControl("Label28")).Text = ((Label)GridView2.Rows[0].FindControl("Label8")).Text; 45
46
SqlParameter[] Params3 = new SqlParameter[2]; 47
Params3[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperID); //试卷编号 48
Params3[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "判断题"); //题目类型 49
DataSet ds3 = DB.GetDataSet("Proc_PaperDetail", Params3); 50
GridView3.DataSource = ds3; 51
GridView3.DataBind(); 52
((Label)GridView3.HeaderRow.FindControl("Label29")).Text = ((Label)GridView3.Rows[0].FindControl("Label12")).Text; 53
54
SqlParameter[] Params4 = new SqlParameter[2]; 55
Params4[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperID); //试卷编号 56
Params4[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "填空题"); //题目类型 57
DataSet ds4 = DB.GetDataSet("Proc_PaperDetail", Params4); 58
GridView4.DataSource = ds4; 59
GridView4.DataBind(); 60
((Label)GridView4.HeaderRow.FindControl("Label30")).Text = ((Label)GridView4.Rows[0].FindControl("Label17")).Text; 61
} 62
} 63





}
}