📄 webform1.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;
namespace TheClient
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.DropDownList DropDownList1;
protected System.Web.UI.WebControls.Button RunSql;
protected System.Web.UI.WebControls.Button Populate;
protected System.Web.UI.WebControls.Label messages;
private localhost.dbService mydbService = new localhost.dbService();
public WebForm1()
{
Page.Init += new System.EventHandler(Page_Init);
}
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}
private void Page_Init(object sender, EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
}
#region Web Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Populate.Click += new System.EventHandler(this.Populate_Click);
this.RunSql.Click += new System.EventHandler(this.RunSql_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Populate_Click(object sender, System.EventArgs e)
{
DataSet ds = new DataSet();
String s = DropDownList1.SelectedItem.ToString();
ds = mydbService.Populate(s);
DataGrid1.DataSource=ds;
DataGrid1.DataBind();
}
private void RunSql_Click(object sender, System.EventArgs e)
{
string s;
String ret;
s = "Delete from pub_info where pub_id = '9999'";
ret=mydbService.RunSQL(s);
messages.Text= ret;
//insert a random number
Random r = new Random();
s = " insert into pub_info(pub_id,pr_info) values(";
s = s + " '9999','" + r.Next(1000).ToString() + "')";
ret = mydbService.RunSQL(s);
messages.Text= ret;
//Refresh the DataGrid to show changes
DataSet ds = new DataSet();
s = "Select * from pub_info where pub_id = '9999'";
ds = mydbService.Populate(s);
DataGrid1.DataSource=ds;
DataGrid1.DataBind();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -