页面代码如下:
<%@Import Namespace="System.Data"%>
<%@Import Namespace="System.Data.OleDb"%>
<%@ Page Language="C#" Debug="true" %>
<script language="C#" runat="server">
void Page_Load(Object sender, EventArgs e)
{
string strid;
strid=Request.QueryString["id"];
int id=Convert.ToInt32(strid);
string strsql;
strsql="select * from admin where adminid="+id;
string strConnection="Provider=Microsoft.Jet.OleDb.4.0;Data Source="+Server.MapPath("new.mdb");
OleDbConnection objConnection=new OleDbConnection(strConnection);
objConnection.Open();
OleDbCommand objCommand = new OleDbCommand(strsql,objConnection);
OleDbDataReader objDataReader=objCommand.ExecuteReader();
if (objDataReader.Read())
{
username.Text=Convert.ToString(objDataReader["username"]);
password.Text=Convert.ToString(objDataReader["password"]);
}
objDataReader.Close();
}
void but_click(Object sender, EventArgs e)
{
string strid;
strid=Request.QueryString["id"];
int id=Convert.ToInt32(strid);
string strsql;
string username=Request["username"];
string password=Request["password"];
strsql="update admin set username='"+username+"',[password]='"+password+"' where adminid="+id;
string strConnection="Provider=Microsoft.Jet.OleDb.4.0;Data Source="+Server.MapPath("new.mdb");
OleDbConnection objConnection=new OleDbConnection(strConnection);
OleDbCommand objCommand1 = new OleDbCommand(strsql,objConnection);
objConnection.Open();
objCommand1.ExecuteNonQuery();
Response.Redirect("data_list.aspx");
}
</script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>用户编辑</title>
</head>
<body>
<form runat="server">
<table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<tr bgcolor="#FFFFFF">
<td width="141" height="22" align="right">用户名:</td>
<td width="256"><asp:textbox runat="server" ID="username" /></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="22" align="right">密 码:</td>
<td> <asp:textbox runat="server" ID="password" /></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="22"> </td>
<td><asp:button runat="server" OnClick="but_click" Text="更 新" ID="but"/></td>
</tr>
</table>
</form>
</body>
</html>
数据更新后跳转到data_list.aspx,可是我发现数据并没有更新,只有刷新后才显示更新后的数据,这是为什么啊
我想跳转后就可以直接看到更新的数据,该怎么改呢?