0
我使用的DevExpress的GridView和有此代碼從另一個控制的customcallback刪除選定gridview的行,ASPxGridView DeleteRow不刪除另一個控制回調
行
GridFrom.DeleteRow(INT .Parse(rowKey [2]));
檢索正確的visibleIndex但不從GridView中刪除該行。該數據綁定也沒有刷新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 [email protected]";
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();
}
}
嘗試刪除'GridFrom.DataBind();',因爲不是所有的數據源都支持刪除方法。你確定該文件已被刪除數據庫? – Dani