private void Page_Load(object sender, System.EventArgs e)
{
string StrSql="";
conn.open();
StrSql="select * from cpjs where id="+Request.QueryString["id"];
OleDbCommand mycommand=new OleDbCommand(StrSql,conn.dbconn);
OleDbDataReader myReader=mycommand.ExecuteReader();
if(myReader.Read())
{
this.fzmz1.Text=myReader.GetString(4);
this.fzys1.Text=myReader.GetString(2);
this.fzjg1.Text=myReader.GetString(3);
this.fzjs1.Text=myReader.GetString(5);
}
else
{
Response.Write ("<script>alert('当前没有记录,请返回!!');history.go(-1);</script>");
}
myReader.Close();
mycommand.Dispose();
conn.close();
}
原来代码如下:
namespace flashfz.qruanadmin
{
/// <summary>
/// addcpjs 的摘要说明。
/// </summary>
public class editcpjs : System.Web.UI.Page
{
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
protected System.Web.UI.WebControls.TextBox fzys1;
protected System.Web.UI.WebControls.RequiredFieldValidator Requiredfieldvalidator2;
protected System.Web.UI.WebControls.TextBox fzjg1;
protected System.Web.UI.WebControls.RequiredFieldValidator Requiredfieldvalidator3;
protected System.Web.UI.WebControls.TextBox fzjs1;
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator4;
protected System.Web.UI.HtmlControls.HtmlInputButton Submit2;
protected System.Web.UI.WebControls.TextBox fzmz1;
protected config conn=new config();
private void Page_Load(object sender, System.EventArgs e)
{
string StrSql="";
conn.open();
StrSql="select * from cpjs where id="+Request.QueryString["id"];
OleDbCommand mycommand=new OleDbCommand(StrSql,conn.dbconn);
OleDbDataReader myReader=mycommand.ExecuteReader();
if(myReader.Read())
{
this.fzmz1.Text=myReader.GetString(4);
this.fzys1.Text=myReader.GetString(2);
this.fzjg1.Text=myReader.GetString(3);
this.fzjs1.Text=myReader.GetString(5);
}
else
{
Response.Write ("<script>alert('当前没有记录,请返回!!');history.go(-1);</script>");
}
myReader.Close();
mycommand.Dispose();
conn.close();
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Submit2.ServerClick += new System.EventHandler(this.Submit2_ServerClick);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Submit2_ServerClick(object sender, System.EventArgs e)
{
string Sql="";
conn.open();
Sql="UPDATE cpjs set fzmz='"+this.fzmz1.Text+"',fzys='"+this.fzys1.Text+"',fzjg='"+this.fzjg1.Text+"',fzjs='"+this.fzjs1.Text+"' where id="+Request.QueryString["id"];
OleDbCommand mycommand=new OleDbCommand(Sql,conn.dbconn);
mycommand.ExecuteNonQuery();
mycommand.Dispose();
conn.close();
Response.Write("<script>alert('修改成功!!');location.href='cpjs.aspx';</script>");
}
}
}