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();
}
}
it requires refreshing of the page for the data to update
您看不到网格变化,因为 ONLY ASPxTreeList 在 ITS OWN 回调期间更新。
作为一种可能的解决方案,禁用 ASPxTreeList 的回调或使用网格的 CustomCallback 删除网格行(以类似的方式)。
<dx:ASPxTreeList ID="ASPxTreeList1" runat="server" EnableCallbacks="false">
</dx:ASPxTreeList>
查看有关此的 The concept of callbacks - Why is it impossible to update external control data during a callback to another control 学习指南。
我正在使用 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();
}
}
it requires refreshing of the page for the data to update
您看不到网格变化,因为 ONLY ASPxTreeList 在 ITS OWN 回调期间更新。
作为一种可能的解决方案,禁用 ASPxTreeList 的回调或使用网格的 CustomCallback 删除网格行(以类似的方式)。
<dx:ASPxTreeList ID="ASPxTreeList1" runat="server" EnableCallbacks="false">
</dx:ASPxTreeList>
查看有关此的 The concept of callbacks - Why is it impossible to update external control data during a callback to another control 学习指南。