簡體   English   中英

ASPxGridView DeleteRow不刪除另一個控件回調

[英]ASPxGridView DeleteRow not deleting on another control callback

我正在使用DEVExpress的gridview,並使用此代碼從另一個控件的customcallback中刪除選定的gridview行,

GridFrom.DeleteRow(int.Parse(rowKey [2]));

檢索正確的visibleIndex,但不會從gridview中刪除該行。 databind也不會刷新gridview的數據,它需要刷新頁面以更新數據

    protected void ASPxTreeList1_CustomCallback(object sender, DevExpress.Web.ASPxTreeList.TreeListCustomCallbackEventArgs e)
    {
        string[] rowKey = e.Argument.Split('|');

        string strConnectionString = ConfigurationManager.ConnectionStrings["dbname"].ConnectionString;
        using (SqlConnection conn = new SqlConnection(strConnectionString))
        {
            string query = "DELETE FROM Table WHERE id=@id";

            using (SqlCommand cmd = new SqlCommand(query, conn))
            {
                conn.Open();
                cmd.Parameters.AddWithValue("@id", rowKey[0]);
                cmd.ExecuteNonQuery();
                conn.Close();
            }

        }
        GridFrom.DeleteRow(int.Parse(rowKey[2])); //rowKey[2] is the visibleIndex
        GridFrom.DataBind();
    }
}

它需要刷新頁面以更新數據

您不會看到網格更改,因為 ASPxTreeList在ITS OWN回調期間進行了更新。

作為一種可能的解決方案,請禁用ASPxTreeList的回調或使用網格的CustomCallback刪除網格行(以類似的方式)。

<dx:ASPxTreeList ID="ASPxTreeList1" runat="server" EnableCallbacks="false">
</dx:ASPxTreeList>

選中“ 回調的概念-為什么在回調期間無法更新外部控制數據到另一本與此相關的控件學習指南”。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM