您好,登錄后才能下訂單哦!
前臺:
<%@PageLanguage="C#"AutoEventWireup="true"CodeBehind="infoset.aspx.cs"Inherits="WebApplication2.infoset"%>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title></title>
</head>
<body>
<formid="form1"runat="server">
<div>
<div>姓名:<asp:TextBoxrunat="server"ID="txt_uname"></asp:TextBox></div>
<div>學(xué)號:<asp:TextBoxrunat="server"ID="txt_code"></asp:TextBox></div>
<div>學(xué)校:<asp:TextBoxrunat="server"ID="txt_school"></asp:TextBox></div>
<div><asp:Buttonrunat="server"ID="btn_save"Text="添加"/></div>
</div>
</form>
</body>
</html>
后臺:
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Web;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
usingSystem.Data;
usingSystem.Data.SqlClient;
namespaceWebApplication2
{
publicpartialclassinfoset:System.Web.UI.Page
{
protectedoverridevoidOnInit(EventArgse)
{
btn_save.Click+=btn_save_Click;
base.OnInit(e);
}
voidbtn_save_Click(objectsender,EventArgse)
{
if(Request.QueryString["id"]!=null)
{
blltest.bllStudent.edit(int.Parse(Request.QueryString["id"]),txt_uname.Text,txt_code.Text,txt_school.Text);
form1.Controls.Add(newLiteralControl("<script>alert('修改成功');location.href='GridView.aspx';</script>"));
}
else
{
blltest.bllStudent.Add(txt_uname.Text,txt_code.Text,txt_school.Text);
form1.Controls.Add(newLiteralControl("<script>alert('添加成功');location.href='GridView.aspx';</script>"));
}
}
protectedvoidPage_Load(objectsender,EventArgse)
{
if(Request.QueryString["id"]!=null)
{
DataTabledt=blltest.bllStudent.ReadData(int.Parse(Request.QueryString["id"]));
DataRowdr=dt.Rows[0];
txt_code.Text=dr["code"].ToString();
txt_school.Text=dr["school"].ToString();
txt_uname.Text=dr["uname"].ToString();
btn_save.Text="修改";
}
}
}
}
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。