遇到个可无奈的问题!
例如我在 Button1_Click 里写个this.xindian(); 但是代码执行到a就完了!
并不会再在xindian;方法里去执行xindian; 的代码! 只有页面再刷新时候才会执行!
下面是我的代码 有点乱!见谅!
public partial class main : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string name = Session["name"].ToString();
this.quanxian();
}
}
public void quanxian()
{
string name1 = Session["name"].ToString();
OleDbConnection olc = DB.CreateDb();
olc.Open();
OleDbCommand olm = new OleDbCommand("select * from manager where [username] = '" + name1 + "' ", olc);
OleDbDataAdapter ola = new OleDbDataAdapter();
DataSet ds = new DataSet();
ola.SelectCommand = olm;
ola.Fill(ds);
this.GridView1.DataSource = ds.Tables[0];
this.GridView1.DataBind();
}
protected void Button1_Click(object sender, EventArgs e)
{
this.divyingxiao.Visible = true;
this.divnews.Visible = false;
this.xindian();
}
protected void Button2_Click(object sender, EventArgs e)
{
this.divnews.Visible = true;
this.divyingxiao.Visible = false;
}
public void xindian()
{
OleDbConnection oln = DB.CreateDb();
oln.Open();
OleDbDataAdapter olp = new OleDbDataAdapter();
OleDbCommand olm = new OleDbCommand("select * from shoplist", oln);
DataSet dst = new DataSet();
olp.SelectCommand = olm;
olp.Fill(dst);
this.GridView2.DataSource = dst.Tables[0];
this.GridView2.DataKeyNames = new string[] { "ID" };
this.GridView2.DataBind();
}
protected void GridView2_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
int did = Convert.ToInt32(this.GridView2.DataKeys[e.RowIndex].Value.ToString());
if (DB.shan("delete from shoplist where [ID]=" + did + ""))
{
this.xindian();
}
}
}
我删除后 页面还会显示被删的, 只有页面再次打时才不会显示! 在线等!
例如我在 Button1_Click 里写个this.xindian(); 但是代码执行到a就完了!
并不会再在xindian;方法里去执行xindian; 的代码! 只有页面再刷新时候才会执行!
下面是我的代码 有点乱!见谅!
public partial class main : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string name = Session["name"].ToString();
this.quanxian();
}
}
public void quanxian()
{
string name1 = Session["name"].ToString();
OleDbConnection olc = DB.CreateDb();
olc.Open();
OleDbCommand olm = new OleDbCommand("select * from manager where [username] = '" + name1 + "' ", olc);
OleDbDataAdapter ola = new OleDbDataAdapter();
DataSet ds = new DataSet();
ola.SelectCommand = olm;
ola.Fill(ds);
this.GridView1.DataSource = ds.Tables[0];
this.GridView1.DataBind();
}
protected void Button1_Click(object sender, EventArgs e)
{
this.divyingxiao.Visible = true;
this.divnews.Visible = false;
this.xindian();
}
protected void Button2_Click(object sender, EventArgs e)
{
this.divnews.Visible = true;
this.divyingxiao.Visible = false;
}
public void xindian()
{
OleDbConnection oln = DB.CreateDb();
oln.Open();
OleDbDataAdapter olp = new OleDbDataAdapter();
OleDbCommand olm = new OleDbCommand("select * from shoplist", oln);
DataSet dst = new DataSet();
olp.SelectCommand = olm;
olp.Fill(dst);
this.GridView2.DataSource = dst.Tables[0];
this.GridView2.DataKeyNames = new string[] { "ID" };
this.GridView2.DataBind();
}
protected void GridView2_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
int did = Convert.ToInt32(this.GridView2.DataKeys[e.RowIndex].Value.ToString());
if (DB.shan("delete from shoplist where [ID]=" + did + ""))
{
this.xindian();
}
}
}
我删除后 页面还会显示被删的, 只有页面再次打时才不会显示! 在线等!
解决方案 »
- FileUpload?????
- 页面无刷新已实现,求聊天内容显示在textbox的最底端方法[求助]
- 怎样生成可以附加数据库的MDF和LDF文件?
- objectdatasource可否接受数组类型的参数
- 设置前景颜色。。。会JS的进来看一下。。不胜感激。。。。
- gif图片用Image.GetThumbnailImage(..)缩略后不能动了,变成静态图片了
- 请问RSS的标准格式 RSS1.0 和 RSS2.0 规范差别??
- asp.net网站 修改 修改权限带来的麻烦 高分请教
- 因为状态栏没有显示?
- 各位午夜好呀,抽空散分……
- 请问怎么在后台的.cs代码里随机产生一个int ID标识呢?
- asp.net改写xml文件的问题
看完你的代码我也很无奈,写句注释好不好!- -!
if (DB.shan("delete from shoplist where [ID]=" + did.ToString() + ""))
{
Response.Expires = -1;
protected void GridView2_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
int did = Convert.ToInt32(this.GridView2.DataKeys[e.RowIndex].Value.ToString());
if (DB.shan("delete from shoplist where [ID]=" + did + ""))
{
this.xindian(); }
} 红色部分
{
int did = Convert.ToInt32(this.GridView2.DataKeys[e.RowIndex].Value.ToString());
DB.shan("delete from shoplist where [ID]=" + did + "");
this.xindian();
}
----> 如果上面不行,这样:protected void GridView2_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
int did = Convert.ToInt32(this.GridView2.DataKeys[e.RowIndex].Value.ToString());
DB.shan("delete from shoplist where [ID]=" + did + ""); Response.Redirect(当前页面);
}
实在不行 加上这句
Response.Redirect(this.Page.Request.Url.ToString());
至于其他的暂时还没看出毛病