[英]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.