?? overlook.aspx.cs
字號:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
namespace OLTest
{
/// <summary>
/// OverLook 的摘要說明。
/// </summary>
public class OverLook : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Button Button2;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.Button Button3;
protected System.Web.UI.WebControls.Button Button4;
DataSet ds;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此處放置用戶代碼以初始化頁面
Button3.Visible=false;
Button4.Visible=false;
Label2.Visible=false;
BindData();
}
public void BindData()
{
string[] temp=Session["Num"].ToString().Split(',');
string cn="server=.;uid=sa;database=nTest";
SqlDataAdapter da=new SqlDataAdapter("Select * from Question ",cn);
ds=new DataSet();
da.Fill(ds);
DataSet ds1=new DataSet();
ds1=ds.Clone();
string[] GetCNum=Session["uAnswer"].ToString().TrimEnd(',').Split(',');
string[] tempSign=Session["Sign"].ToString().Split(',');
for (int i=0;i<GetCNum.GetLength(0);i++)
{
DataRow dr=ds1.Tables[0].NewRow();
dr["Quest"]=ds.Tables[0].Rows[Convert.ToInt32(temp[i])-1]["Quest"];
dr["A"]=i+1;
if(Convert.ToInt32(tempSign[i])==1)
{
dr["B"]="是" ;
}
else
{
dr["B"]="否";
}
ds1.Tables[0].Rows.Add(dr);
}
DataGrid1.DataSource=ds1;
DataGrid1.DataBind();
}
#region Web 窗體設計器生成的代碼
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 該調用是 ASP.NET Web 窗體設計器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 設計器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內容。
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.DataGrid1.ItemCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.Look);
this.DataGrid1.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.DataGrid1_ItemDataBound);
this.Button2.Click += new System.EventHandler(this.Button2_Click);
this.Button3.Click += new System.EventHandler(this.Button3_Click);
this.Button4.Click += new System.EventHandler(this.Button4_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Button1_Click(object sender, System.EventArgs e)
{
this.Response.Redirect("Main.aspx");
}
private void Look(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
int CNum=e.Item.DataSetIndex;
Session["Current"]=CNum;
Response.Redirect("Main.aspx");
}
private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
}
private void Button2_Click(object sender, System.EventArgs e)
{
Button3.Visible=true;
Button4.Visible=true;
Label2.Visible=true;
}
private void Button3_Click(object sender, System.EventArgs e)
{
string[] GetCNum=Session["uAnswer"].ToString().TrimEnd(',').Split(',');
if (GetCNum.GetLength(0)==10)
{
this.Response.Redirect("Post.aspx");
}
else
{
Label1.Text="您尚未完成試卷!";
}
}
private void Button4_Click(object sender, System.EventArgs e)
{
this.Response.Redirect("OverLook.aspx");
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -