📄 contract.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
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.Configuration;
namespace cms
{
/// <summary>
/// contract 的摘要说明。
/// </summary>
public class contract : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid Dgd_contract;
protected System.Web.UI.WebControls.Button Btn_exit;
SqlConnection cn;
private void Page_Load(object sender, System.EventArgs e)
{//判断用户是否为合法用户
try
{
if(Session["User_power"].ToString ()=="0"||Session["User_power"].ToString ()=="1");
else
{
Response.End ();
}
}
catch
{
Response.Write ("您不是合法用户,请登入后再操作,<a href='default.aspx'>返回</a>");
Response.End ();
}
// 在此处放置用户代码以初始化页面
string strconn= ConfigurationSettings.AppSettings["dsn"];
cn=new SqlConnection(strconn);
if(!IsPostBack)
BindGrid();
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Btn_exit.Click += new System.EventHandler(this.Btn_exit_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
public void BindGrid()
{
SqlDataAdapter da=new SqlDataAdapter("select * from contract",cn);
DataSet ds=new DataSet();
da.Fill(ds);
Dgd_contract.DataSource=ds;
Dgd_contract.DataBind();
}
public void DataGrid_Page(object sender,DataGridPageChangedEventArgs e)
{
Dgd_contract.CurrentPageIndex=e.NewPageIndex;
BindGrid();
}
private void Btn_exit_Click(object sender, System.EventArgs e)
{
Response.Redirect("default.aspx");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -