📄 new_profession.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using jianke;
public partial class new_profession : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ if(!IsPostBack)
Dept_Bind();
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection Conn = DB.creatconnection();
Conn.Open();
string str = "insert into Profession(dept_id,profession_name)values("+this.DropDownList1.SelectedValue+",'" + this.TextBox1.Text + "')";
SqlCommand cmd = new SqlCommand(str, Conn);
cmd.ExecuteNonQuery();
Conn.Close();
Response.Write("<script>alert('录入成功!');</script>");
this.TextBox1.Text = "";
}
public void Dept_Bind()
{
SqlConnection Conn = DB.creatconnection();
Conn.Open();
SqlCommand cmd = new SqlCommand("select dept_name,dept_id from Dept", Conn);
SqlDataReader sdr = cmd.ExecuteReader();
this.DropDownList1.DataSource = sdr;
this.DropDownList1.DataTextField = "dept_name";
this.DropDownList1.DataValueField = "dept_id";
this.DropDownList1.DataBind();
sdr.Close();
Conn.Close();
}
protected void Button2_Click(object sender, EventArgs e)
{
this.TextBox1.Text = "";
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -