前台代码
:
<%@ Page Language="C#" AutoEventWireup="true" Debug ="true" CodeFile="Edit.aspx.cs" Inherits="admin_Edit" validateRequest="false" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>报名</title>
<link href="css.css" rel="stylesheet" type="text/css" />
<%-- <link href="Adminstyle.css" rel="stylesheet" type="text/css" />--%>
</head>
<body style="margin-top: 0px; padding-top: 0px">
<form id="form1" runat="server">
<div>
<table border="0" cellpadding="0" cellspacing="1"
height="100" style="width: 95%">
<tr>
<td bgcolor="#d1e7fc" style="height: 22px; " align="center">
<div align="center" style="font-size: 20pt">
信息编辑</div>
</td>
</tr>
<tr>
<td align="left" valign="top" style="height: 420px; ">
<table style=" height: 100px; width: 100%; vertical-align: middle; direction: ltr; text-align: left;" border ="0">
<tr>
<td style=" border-bottom: 1px solid; width: 107px;" align="right">
学 员:</td>
<td style=" border-bottom: 1px solid; width: 1100px;">
<asp:TextBox ID="txtname" runat="server" CssClass="txt" MaxLength="15" Width="225px"></asp:TextBox> </td>
</tr>
<tr style="color: #000000">
<td style=" border-bottom: 1px solid; width: 107px;" align="right">
身份证号:</td>
<td style=" border-bottom: 1px solid; width: 1100px;">
<asp:TextBox ID="txtcard" runat="server" Width="226px"></asp:TextBox></td>
</tr>
<tr style="color: #000000">
<td style=" border-bottom: 1px solid; width: 107px;" align="right">
单位:</td>
<td style=" border-bottom: 1px solid; width:1100px;">
<asp:TextBox ID="txtunit" runat="server" Width="225px"></asp:TextBox></td>
</tr>
<tr style="color: #000000">
<td style=" border-bottom: 1px solid; width: 107px;" align="right">
职业:</td>
<td style=" border-bottom: 1px solid; width:1100px;">
<asp:TextBox ID="txtwork" runat="server" Width="226px" ></asp:TextBox></td>
</tr>
<tr>
<td style=" height: 26px; width: 107px;" align="right">
</td>
<td align="center" style=" height: 26px; width: 216px;">
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="保 存" Width="66px" />
<asp:Button ID="Button2" runat="server" CausesValidation="False" OnClick="Button2_Click"
Text="重 置" /></td>
</tr>
</table>
<asp:Image ID="Image1" runat="server" /></td>
</tr>
</table>
</div>
</form>
</body>
</html>
后台代码: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;public partial class admin_Edit : System.Web.UI.Page
{
BaseClass bc = new BaseClass();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataSet ds = bc.GetDataSet("select * from login where uid='" + Request.QueryString["id"] + "'", "login");//获取列表页面的数据ID
DataRow[] row = ds.Tables[0].Select();
foreach (DataRow rs in row)
{ txtname.Text = rs["Uname"].ToString();
txtcard.Text = rs["UcardId"].ToString();
txtunit.Text = rs["Uunit"].ToString();
txtwork.Text = rs["Ucategory"].ToString();
}
}
}
protected void Button1_Click(object sender, EventArgs e)
{
try
{
string sql = "UPDATE login SET Uname = '" + txtname.Text +
"', UcardId = '" + txtcard.Text + "', Uunit = '" + txtunit.Text + "', Ucategory = '" + txtwork.Text + "' WHERE (UID = '" + Request.QueryString["id"] + "')";
bc.ExecSQL(sql);
Response.Write(bc.MessageBox("数据修改成功!"));
Response.Write("<script>location='stulist.aspx'</script>");
}
catch
{
Response.Write("<script language=javascript>alert('很遗憾!信息更新失败!')</script>");
}
}
protected void Button2_Click(object sender, EventArgs e)
{
txtname.Text = "";
txtcard.Text = "";
txtunit.Text = "";
txtwork.Text = "";
}
}
:
<%@ Page Language="C#" AutoEventWireup="true" Debug ="true" CodeFile="Edit.aspx.cs" Inherits="admin_Edit" validateRequest="false" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>报名</title>
<link href="css.css" rel="stylesheet" type="text/css" />
<%-- <link href="Adminstyle.css" rel="stylesheet" type="text/css" />--%>
</head>
<body style="margin-top: 0px; padding-top: 0px">
<form id="form1" runat="server">
<div>
<table border="0" cellpadding="0" cellspacing="1"
height="100" style="width: 95%">
<tr>
<td bgcolor="#d1e7fc" style="height: 22px; " align="center">
<div align="center" style="font-size: 20pt">
信息编辑</div>
</td>
</tr>
<tr>
<td align="left" valign="top" style="height: 420px; ">
<table style=" height: 100px; width: 100%; vertical-align: middle; direction: ltr; text-align: left;" border ="0">
<tr>
<td style=" border-bottom: 1px solid; width: 107px;" align="right">
学 员:</td>
<td style=" border-bottom: 1px solid; width: 1100px;">
<asp:TextBox ID="txtname" runat="server" CssClass="txt" MaxLength="15" Width="225px"></asp:TextBox> </td>
</tr>
<tr style="color: #000000">
<td style=" border-bottom: 1px solid; width: 107px;" align="right">
身份证号:</td>
<td style=" border-bottom: 1px solid; width: 1100px;">
<asp:TextBox ID="txtcard" runat="server" Width="226px"></asp:TextBox></td>
</tr>
<tr style="color: #000000">
<td style=" border-bottom: 1px solid; width: 107px;" align="right">
单位:</td>
<td style=" border-bottom: 1px solid; width:1100px;">
<asp:TextBox ID="txtunit" runat="server" Width="225px"></asp:TextBox></td>
</tr>
<tr style="color: #000000">
<td style=" border-bottom: 1px solid; width: 107px;" align="right">
职业:</td>
<td style=" border-bottom: 1px solid; width:1100px;">
<asp:TextBox ID="txtwork" runat="server" Width="226px" ></asp:TextBox></td>
</tr>
<tr>
<td style=" height: 26px; width: 107px;" align="right">
</td>
<td align="center" style=" height: 26px; width: 216px;">
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="保 存" Width="66px" />
<asp:Button ID="Button2" runat="server" CausesValidation="False" OnClick="Button2_Click"
Text="重 置" /></td>
</tr>
</table>
<asp:Image ID="Image1" runat="server" /></td>
</tr>
</table>
</div>
</form>
</body>
</html>
后台代码: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;public partial class admin_Edit : System.Web.UI.Page
{
BaseClass bc = new BaseClass();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataSet ds = bc.GetDataSet("select * from login where uid='" + Request.QueryString["id"] + "'", "login");//获取列表页面的数据ID
DataRow[] row = ds.Tables[0].Select();
foreach (DataRow rs in row)
{ txtname.Text = rs["Uname"].ToString();
txtcard.Text = rs["UcardId"].ToString();
txtunit.Text = rs["Uunit"].ToString();
txtwork.Text = rs["Ucategory"].ToString();
}
}
}
protected void Button1_Click(object sender, EventArgs e)
{
try
{
string sql = "UPDATE login SET Uname = '" + txtname.Text +
"', UcardId = '" + txtcard.Text + "', Uunit = '" + txtunit.Text + "', Ucategory = '" + txtwork.Text + "' WHERE (UID = '" + Request.QueryString["id"] + "')";
bc.ExecSQL(sql);
Response.Write(bc.MessageBox("数据修改成功!"));
Response.Write("<script>location='stulist.aspx'</script>");
}
catch
{
Response.Write("<script language=javascript>alert('很遗憾!信息更新失败!')</script>");
}
}
protected void Button2_Click(object sender, EventArgs e)
{
txtname.Text = "";
txtcard.Text = "";
txtunit.Text = "";
txtwork.Text = "";
}
}
论坛签名======================================================================
当您的问题得到解答后请及时结贴.
http://topic.csdn.net/u/20090501/15/7548d251-aec2-4975-a9bf-ca09a5551ba5.html
http://topic.csdn.net/u/20100428/09/BC9E0908-F250-42A6-8765-B50A82FE186A.html
http://topic.csdn.net/u/20100626/09/f35a4763-4b59-49c3-8061-d48fdbc29561.html如何给分和结贴?
http://community.csdn.net/Help/HelpCenter.htm#结帖如何给自己的回帖中也加上签名?
http://blog.csdn.net/q107770540/archive/2011/03/15/6250007.aspx