原文发布时间为:2008-07-30 —— 来源于本人的百度文章 [由搬家工具导入]
可以在detailsview的事件中添加如下语句,即增加一个头,让它在0秒的时候刷新:
Response.AddHeader("refresh", "0,url=Default2.aspx");
完整源码:
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;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void DetailsView1_ItemUpdated(object sender, DetailsViewUpdatedEventArgs e)
{
Response.AddHeader("refresh", "0,url=Default2.aspx");//为了防止detailsview中修改后,而girdview却没更新
}
protected void DetailsView1_ItemDeleted(object sender, DetailsViewDeletedEventArgs e)
{
Response.AddHeader("refresh", "0,url=Default2.aspx");
}
protected void DetailsView1_ItemInserted(object sender, DetailsViewInsertedEventArgs e)
{
Response.AddHeader("refresh", "0,url=Default2.aspx");
}
protected void DetailsView2_ItemInserted(object sender, DetailsViewInsertedEventArgs e)
{
Response.AddHeader("refresh", "0,url=Default2.aspx");
}
}