ASP.NET中添加完信息之后怎么刷新页面
我添加一个数据,但是GridView在添加不会刷新。GridView还是原来的界面。下面是我的代码,问应该增加什么样的代码,才能让添加完数据之后GridView跟着更新?...
我添加一个数据,但是GridView在添加不会刷新。GridView还是原来的界面。
下面是我的代码,问应该增加什么样的代码,才能让添加完数据之后GridView跟着更新?
protected void Button3_Click(object sender, EventArgs e)
{
string ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" + Server.MapPath("~/app_data/db5.mdb");
OleDbConnection conn = new OleDbConnection(ConStr);
conn.Open();
string SQLStr = "INSERT INTO xuankebiao(cno,cname,csequence,credit,cteacher,ctime,caddr) VALUES('" + cno.Text + "','" + cname.Text + "','" + csequence.Text + "','" + credit.Text + "','" + cteacher.Text + "','" + ctime.Text + "','" + caddr.Text + "')";
OleDbCommand cmd = new OleDbCommand(SQLStr, conn);
cmd.ExecuteNonQuery();
SQLStr = "SELECT*FROM xuankebiao ORDER BY cno";
OleDbDataAdapter da = new OleDbDataAdapter(SQLStr, conn);
DataSet ds = new DataSet();
da.Fill(ds);
GridView gv = new GridView();
conn.Close();
Response.Write("<script language=javascript>alert('添加成功')</script>");
} 展开
下面是我的代码,问应该增加什么样的代码,才能让添加完数据之后GridView跟着更新?
protected void Button3_Click(object sender, EventArgs e)
{
string ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" + Server.MapPath("~/app_data/db5.mdb");
OleDbConnection conn = new OleDbConnection(ConStr);
conn.Open();
string SQLStr = "INSERT INTO xuankebiao(cno,cname,csequence,credit,cteacher,ctime,caddr) VALUES('" + cno.Text + "','" + cname.Text + "','" + csequence.Text + "','" + credit.Text + "','" + cteacher.Text + "','" + ctime.Text + "','" + caddr.Text + "')";
OleDbCommand cmd = new OleDbCommand(SQLStr, conn);
cmd.ExecuteNonQuery();
SQLStr = "SELECT*FROM xuankebiao ORDER BY cno";
OleDbDataAdapter da = new OleDbDataAdapter(SQLStr, conn);
DataSet ds = new DataSet();
da.Fill(ds);
GridView gv = new GridView();
conn.Close();
Response.Write("<script language=javascript>alert('添加成功')</script>");
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询