[求助]怎样提交表单后马上显示添加后的数据?
<%@ Page Language="C#" Debug="True" %>
<%@ Register TagPrefix="wmx" Namespace="Microsoft.Saturn.Framework.Web.UI" Assembly="Microsoft.Saturn.Framework, Version=0.5.464.0, Culture=neutral, PublicKeyToken=6f763c9966660626" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDb" %>
<script runat="server">
// Insert page code here
//
void TextBox1_TextChanged(Object sender, EventArgs e) {
}
void Calendar1_SelectionChanged(Object sender, EventArgs e) {
}
void DataGrid1_SelectedIndexChanged(Object sender, EventArgs e) {
}
void Page_load(object sender, EventArgs e){
OleDbConnection cn=new OleDbConnection();
cn.ConnectionString="Provider=microsoft.jet.oledb.4.0;data source="+Server.MapPath("db.mdb");
cn.Open();
OleDbCommand cmd=new OleDbCommand("SELECT * FROM USERS",cn);
OleDbDataAdapter adpt=new OleDbDataAdapter(cmd);
DataSet ds=new DataSet();
adpt.Fill(ds);
DataGrid1.DataSource=ds;
DataGrid1.DataBind();
cn.Close();
}
void Button1_Click(Object sender, EventArgs e) {
OleDbConnection cn=new OleDbConnection();
cn.ConnectionString="Provider=microsoft.jet.oledb.4.0;data source="+Server.MapPath("db.mdb");
cn.Open();
OleDbCommand cmd2=new OleDbCommand("INSERT INTO USERS VALUES('"+TextBox1.Text+"','"+TextBox2.Text+"')",cn);
cmd2.ExecuteNonQuery();
cn.Close();
}
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<p align="center">
<asp:Label id="Label1" runat="server" Font-Bold="True" Font-Size="Large" ForeColor="Blue">Hello !</asp:Label>
</p>
<p align="center">
<asp:DataGrid id="DataGrid1" runat="server" OnSelectedIndexChanged="DataGrid1_SelectedIndexChanged"></asp:DataGrid>
</p>
<p align="center">
</p>
<p align="center">
<asp:TextBox id="TextBox1" runat="server">name</asp:TextBox>
</p>
<p align="center">
<asp:TextBox id="TextBox2" runat="server">password</asp:TextBox>
</p>
<p align="center">
<asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="Submit"></asp:Button>
</p>
<!-- Insert content here -->
</form>
</body>
</html>
添加了新的数据提交后却并不显示刚添加的数据,很不爽,而且textbox里就变成刚提交的内容,而没有变回name 和 password ,也很不爽。要怎样改才能不这样呢?