datawindow.net 为什么保存不了UpdateData不好使,代码如下:
 Sybase.DataWindow.AdoTransaction SQLCA;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Bind();
            //SQLCA.Connection.Close();
        }
    }
    private void Bind()
    {  
        SQLCA = new Sybase.DataWindow.AdoTransaction(DataConnection.GetConnection());
        SQLCA.BindConnection();
        dw_test.SetTransaction(SQLCA);
        dw_test.Retrieve("ldj");
        SQLCA.Connection.Close();
    }    protected void btnLoad_Click(object sender, EventArgs e)
    {
        Bind();
    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        Bind();
        dw_test.InsertRow(0);
    }
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        Response.Write(dw_test.ModifiedCount);
        //if (dw_test.ModifiedCount > 0||dw_test.DeletedCount > 0)
       // {
            try
            {
                SQLCA = new Sybase.DataWindow.AdoTransaction(DataConnection.GetConnection());
                
                SQLCA.BindConnection();
                dw_test.SetTransaction(SQLCA);
                SQLCA.Transaction = SQLCA.Connection.BeginTransaction();
                //dw_test.SetItemString(6, "Templatename", "aaaaa");
                dw_test.UpdateData(true,true);
                SQLCA.Transaction.Commit();
                dw_test.ResetUpdateStatus();
                dw_test.Retrieve("ldj");
            }
            catch (Exception ex)
            {
                SQLCA.Transaction.Rollback();
            }
            finally
            {
                SQLCA.Connection.Close();
            }
        }
    //}
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        Bind();
        int row = dw_test.CurrentRow;
        dw_test.DeleteRow(0);
    }点击btnUpdate保存按钮时,没有错误但是也没有保存,不管我怎么更改数据dw_test.ModifiedCount = 0 为什么,请大侠们帮忙,我困扰好几天了。

解决方案 »

  1.   

    删除“if (!IsPostBack)”这句。不过在复杂的多用户系统中,你应该把页面的数据保存在ViewState中,然后在page_load的时候重新使用这个数据绑定。使用if (!IsPostBack)是明显的错误,在你需要获取控件中的item值的时候就需要重建,此时用if (!IsPostBack)来提高“性能”是空话——连数据都不能保证;在page_load中使用数据库来绑定数据是不明显的错误,在数据库内容频繁更改的时候,页面本应该在page_load中重建上一次页面输出的内容而不是数据库里最新的内容。
      

  2.   

    多谢楼上的指教,已经好了。不过在复杂的多用户系统中,你应该把页面的数据保存在ViewState中,然后在page_load的时候重新使用这个数据绑定。
    这个怎么使用阿,怎么能把数据窗口里的数据存到ViewState中阿。