简体   繁体   English

ASPxGridView DeleteRow不删除另一个控件回调

[英]ASPxGridView DeleteRow not deleting on another control callback

I'm using the DEVExpress's gridview and have this code that deletes the selected gridview row from another control's customcallback, 我正在使用DEVExpress的gridview,并使用此代码从另一个控件的customcallback中删除选定的gridview行,

the line 线

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

retrieves the correct visibleIndex but does not remove the row from the gridview. 检索正确的visibleIndex,但不会从gridview中删除该行。 The databind also does not refreshes the gridview's data and it requires refreshing of the page for the data to update 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();
    }
}

it requires refreshing of the page for the data to update 它需要刷新页面以更新数据

You don't see grid changes, because ONLY ASPxTreeList is updated during ITS OWN callback. 您不会看到网格更改,因为 ASPxTreeList在ITS OWN回调期间进行了更新。

As a possible solution, disable ASPxTreeList's callbacks or delete a grid row using the grid's CustomCallback instead (in a similar manner). 作为一种可能的解决方案,请禁用ASPxTreeList的回调或使用网格的CustomCallback删除网格行(以类似的方式)。

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

Check the The concept of callbacks - Why is it impossible to update external control data during a callback to another control learning guide regarding this. 选中“ 回调的概念-为什么在回调期间无法更新外部控制数据到另一本与此相关的控件学习指南”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM