datagrid刷新问题,重绑定
我的datagrid删除数据后重新绑定dataset,结果执行后数据库已删除(从数据库直接看),而页面仍显示删除数据,点击系统的刷新按钮发现数据更新了,好像是dataset没有更新,而我在删除操作后调用了dataset的重新绑定,为什么没有变化
string sqlstring = "SELECT DSA_LOG_PLAYLIST.ID,MP_MEDIAPLAYER.NAME FROM DSA_LOG_PLAYLIST INNER JOIN MP_MEDIAPLAYER ON DSA_LOG_PLAYLIST.MEDIAPLAYERUNIQUEID = MP_MEDIAPLAYER.UNIQUE_KEY ORDER ";
this.oleDbDataAdapter.SelectCommand.CommandText = sqlstring;
this.oleDbDataAdapter.Fill(this.dataSet11, "DSA_LOG_PLAYLIST ");
bool dataLoaded = FillData();
this.dg_logPlay.DataBind();
[解决办法]
删除后写 Response.Redirect(Request.Url.ToString());
[解决办法]
你跟踪一下看看,应该不能,看看删除后执行绑定了么,dataset里数据是什么
[解决办法]
页面的话,load事件中要加
if (!Ispostback)
[解决办法]
楼主,我怎么没在你的代码中看到GridView.DataSource=某数据源这行代码呢……
[解决办法]
在html代码的head标记中嵌入下列三行代码试试?用于清空页面缓存
<META http-equiv= "Pragma " content= "no-cache ">
<META http-equiv= "Cache-Control " content= "no-cache ">
<META http-equiv= "Expires " content= "0 ">
[解决办法]
删除后绑 DataBind();
[解决办法]
string sqlstring = "SELECT DSA_LOG_PLAYLIST.ID,MP_MEDIAPLAYER.NAME FROM DSA_LOG_PLAYLIST INNER JOIN MP_MEDIAPLAYER ON DSA_LOG_PLAYLIST.MEDIAPLAYERUNIQUEID = MP_MEDIAPLAYER.UNIQUE_KEY ORDER ";
this.oleDbDataAdapter.SelectCommand.CommandText = sqlstring;
这里每次都open一下connection
this.oleDbDataAdapter.Fill(this.dataSet11, "DSA_LOG_PLAYLIST ");
每次filldataset后就关闭一下对应的connection
bool dataLoaded = FillData();
this.dg_logPlay.DataBind();