父窗体后台
public void updateView()
        {
            string str_xuh = CommonStr.Decode(lbxuh.Value);
            string str_pxuh = OleDbDB.GetScalarStr("select pxuh from zd_gzzdlbb where xuh='" + str_xuh + "'");
            string str_temp = (str_xuh == "" ? " is null" : "='" + str_xuh + "'");
            string str_sql = (str_xuh == "" ? "" : ("select " + (str_pxuh == "" ? "null" : str_pxuh) + " xuh,null pxuh,'..' lbmc,'' cjsj,null xzcs,null wjdx,'1' wjlx from dual union all "))
                        + "select xuh,pxuh,lbmc,cjsj,null xzcs,null wjdx,'1' wjlx from zd_gzzdlbb where pxuh" + str_temp + " union all"
                        + " select xuh,wjlb,wjzt,scsj,xzcs,wjdx,'2' wjlx from zd_gzzdwjb where wjlb" + str_temp;            sdsgv.ConnectionString = OleDbDB.ConnString;
            sdsgv.SelectCommand = str_sql;            gv.DataBind();
        }//按钮事件
 protected void btnsx_Click(object sender, EventArgs e)
        {
            updateView();
        }
父窗体前台<asp:Button ID="btnsx" runat="server" OnClick="btnsx_Click" Text="Button"/>function showDwlb()
        {
            shuaxin(window.showModalDialog("zd_dwlb.aspx?str_xuh=" + document.getElementById('<%=lbxuh.ClientID%>').value,window,"dialogWidth:550px;dialogHeight:400px;caption:no;toolbar:no;menubar:no;status:no;help:no;scroll:yes;"));
        }
function shuaxin(returnvalue)
        {
            if(returnvalue == "shuaxin")
            {
                document.getElementById('<%=btnsx.ClientID%>').click();
            }
        }
子窗体后台protected void linkbc_Click(object sender, EventArgs e)
        {
            string str_sql = "";
            if (ViewState["str_lb"] != null)
            {
                //添加
                str_sql = "insert into zd_gzzdlbb (xuh,pxuh,lbmc,lbsm,cjsj) values (sequ_zd_gzzdwjb.nextval,'" + ViewState["str_lb"].ToString() + "',?,?,'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "')";
            }
            else if (ViewState["str_xuh"] != null)
            { //修改
                str_sql = "update zd_gzzdlbb set lbmc=?,lbsm=? where xuh='" + ViewState["str_xuh"] + "'";
            }            OleDbCommand cmd = new OleDbCommand(str_sql);
            cmd.Parameters.Add(new OleDbParameter("lbmc", txt_lbmc.Text));
            cmd.Parameters.Add(new OleDbParameter("lbsm", txt_lbms.Text));            if (OleDbDB.ExeSql(cmd) == 1)
            {
                CommonWeb.RegisterScript("window.returnValue='shuaxin';window.close();");
            }
        }
子窗体更改数据后  返回"shuaxin"给父窗体,父窗体得到"shuaxin"后,js触发按钮事件,,按扭事件就为了重新绑定gridview所有事件,方法都成功被执行...问题在于 gridview没有刷新....而当手动去点击按钮时,,gridview就刷新了...添加了DataBinding事件...js触发的button.click();执行的DataDind未触发DataBinding事件,而手动点击按钮执行的DataBind方法会触发DataBinding事件区别在于js触发和手动点击按钮触发.......怎么解决呀???

解决方案 »

  1.   

    创建一个测试页面,拖个GridView控件上去,随便绑定一下数据,编写DataBinding事件代码,运行看看DataBind能否触发该事件可以为某个特定的问题创建一个排除其他干扰的测试。然后你就知道到底是不是这个问题
      

  2.   

    gridview 没有和数据库绑定吧
      

  3.   

    ASP.NET用的是事件委托机制, 你要用JS也是可以出发的, 你模拟按钮的鼠标单击事件。
      

  4.   

    function shuaxin(returnvalue)
            {
                if(returnvalue == "shuaxin")
                {
                    document.getElementById('<%=btnsx.ClientID%>').click();
                }
            }
    问下楼主这个方法是在哪里调用的?
      

  5.   

    这个方法我也经常用,也没有出现什么问题。楼主看看returnvalue == "shuaxin"是否真的成立了。
      

  6.   

    function showDwlb()
            {
                shuaxin(window.showModalDialog("zd_dwlb.aspx?str_xuh=" + document.getElementById('<%=lbxuh.ClientID%>').value,window,"dialogWidth:550px;dialogHeight:400px;caption:no;toolbar:no;menubar:no;status:no;help:no;scroll:yes;"));
            }
    function shuaxin(returnvalue)
            {
                if(returnvalue == "shuaxin")
                {
                    document.getElementById('<%=btnsx.ClientID%>').click();
                }
            }showDwlb这个方法里就调用 了 shuaxin()
      

  7.   

    无满意答案! 最终解决方法是重新请求页面!  据我所知,绑定GridView的时候,仅第一次去读取数据库!尔后当数据不变时,是不会去读取数据库的!   郁闷的是数据变过的,可却没刷新 !郁闷.相当郁闷 ..