📄 show.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace examonline
{
/// <summary>
/// show 的摘要说明。
/// </summary>
public partial class show : System.Web.UI.Page
{
protected void Page_Load(object sender, System.EventArgs e)
{
if((bool)Session["IsLogined"]==false)
{
Response.Redirect("index.aspx");
}
if(!IsPostBack)
{
Bindgrid();
}
}
private void Bindgrid()
{
SqlConnection cn =new SqlConnection("server=(local);uid=sa;pwd=51aspx;database=examonline");
string sql = "Select exam_title from exam where exam_id="+ Request.QueryString["id"];
SqlCommand cmd = new SqlCommand(sql,cn);
SqlDataReader dr;
cn.Open();
dr=cmd.ExecuteReader();
while(dr.Read())
{
lb_title.Text=dr.GetString(0);
}
cn.Close();
//绑定选择题
sql= "Select question from selectItems where exam_id="+ Request.QueryString["id"];
SqlDataAdapter da =new SqlDataAdapter(sql, cn);
DataSet ds=new DataSet();
try
{
cn.Open();
da.Fill(ds, "selectItems");
}
finally
{
cn.Close();
}
int i=1;
DataTable table=ds.Tables["selectItems"];
foreach(DataRow row in table.Rows)
{
row["question"]=i+"."+(string)row["question"];
i++;
}
dgSelect.DataSource = ds.Tables["selectItems"];
dgSelect.DataBind();
//绑定填空题
sql= "Select question from fillblank where exam_id="+ Request.QueryString["id"];
da.SelectCommand=new SqlCommand(sql, cn);
try
{
cn.Open();
da.Fill(ds, "fillblankItems");
}
finally
{
cn.Close();
}
i=1;
table=ds.Tables["fillblankItems"];
foreach(DataRow row in table.Rows)
{
row["question"]=i+"."+(string)row["question"];
i++;
}
dgFillblank.DataSource = ds.Tables["fillblankItems"];
dgFillblank.DataBind();
//绑定问答题
sql= "Select question from essay where exam_id="+ Request.QueryString["id"];
da.SelectCommand=new SqlCommand(sql, cn);
try
{
cn.Open();
da.Fill(ds, "essayItems");
}
finally
{
cn.Close();
}
i=1;
table=ds.Tables["essayItems"];
foreach(DataRow row in table.Rows)
{
row["question"]=i+"."+(string)row["question"];
i++;
}
dgEssay.DataSource = ds.Tables["essayItems"];
dgEssay.DataBind();
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -