Question

I am developing a GridView that allow editing. I want to disable the warning message of data loss. However its not working.

For example, I edit some field without click the "Save Changes" and then click the column header for sorting, the warning message "Are you sure you want to perform the action? All unsaved grid data will be lost." still alert.

How could I solve this problem?

Here are my sample codes:

TestingWeb.aspx

<form id="form1" runat="server">
    <dx:ASPxGridView ID="ASPxGridView1" runat="server" KeyFieldName="Line" OnRowUpdating="ASPxGridView1_RowUpdating">
        <Columns>
            <dx:GridViewDataTextColumn Caption="Line" FieldName="Line" Name="col_Line" ReadOnly="True" VisibleIndex="1">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Text" FieldName="Text" Name="col_Text" VisibleIndex="2">
            </dx:GridViewDataTextColumn>
        </Columns>
        <SettingsEditing Mode="Batch" BatchEditSettings-ShowConfirmOnLosingChanges="false"></SettingsEditing>
    </dx:ASPxGridView>
</form>

TestingWeb.aspx.cs

protected void Page_Load(object sender, EventArgs e)
{
    DataTable DT = new DataTable();
    DT.Columns.Add("Line");
    DT.Columns.Add("Text");


    DataRow r = DT.NewRow();
    r["Line"] = 1;
    r["Text"] = "Test";

    DT.Rows.Add(r);

    DataColumn[] key = new DataColumn[1];
    key[0] = DT.Columns["Line"];
    DT.PrimaryKey = key;



    ASPxGridView1.DataSource = DT;
    ASPxGridView1.DataBind();

    Session["DataTable"] = DT;
}

protected void ASPxGridView1_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
{
    DevExpress.Web.ASPxGridView.ASPxGridView gridView = (DevExpress.Web.ASPxGridView.ASPxGridView)sender;
    DataTable DT = (DataTable)(Session["DataTable"]);

    DataRow row = DT.Rows.Find(e.Keys[0]);
    IDictionaryEnumerator enumerator = e.NewValues.GetEnumerator();
    enumerator.Reset();

    while (enumerator.MoveNext())
    {
        row[enumerator.Key.ToString()] = enumerator.Value;
    }
    gridView.CancelEdit();
    e.Cancel = true;
    Session["DataTable"] = DT;
}
Was it helpful?

Solution

I updated the version to 13.2.6 and the problem is solved.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top