0
votes

Hoping someone can point me in the right direction

Using DevExpress ASPxGridView and the Edit form.

I need to 'interrupt' the RowInserting events to warn the user if there's already a record matching their information and allow them to continue or cancel.

I've added the check (and a cancel) to the OnRowInserting event and am using customJSProperties to trigger the popup on the callback.

But I'm stuck on how to get the popups 'yes' button to resume (or restart) the Row Insert.

Is there a way of triggering the editform update event again from client side code?

Or do I need a completely different approach?

2

2 Answers

0
votes

First of all, I found this article Use "yes" / "no" in edit mode for boolean value

Second of all, I hope your all rows has a unique value like ID. If so, I sugget a way like this;

  • Use OnRowInserting function of ASPxGridview. (Find here code examples etc.)
  • Check your inserting ID is already in your data store or not. (With running a query)
  • If in your data store or not, use XtraMessageBox like;
XtraMessageBox.Show(“Content”, “Title”, MessageBoxButtons.YesNo);

before that, add DevExpress.XtraEditors namespace. Then you can use it like;

DialogResult myDialogResult;
myDialogResult = XtraMessageBox.Show("Content", "Title", MessageBoxButtons.YesNo);

if (myDialogResult == DialogResult.Yes)
{
    //yes was clicked
}

if (myDialogResult == DialogResult.No)
{
    //no was clicked
}

Hope it gives you an idea. And If you have Devexpress Licence, you can ask in Devexpress Support. They are really quick and helpful.

0
votes

You can solve this with custom HttpHandler. Something like this:

  1. press Save button on your edit form
  2. Save initiates httphandler call (from javascript) with data needed for validation (tablename, id). With jquery you can call http handler like this:
  3. if handler returns true continue with save, otherwise show alert with OK/Cancel
  4. if user chooses OK continue with Save

Javascript call with http handler would look like this:

$.ajax({
    async: false,
    cache: false,
    url: 'YourHttpHandler.ashx',
    data: { tableName: "your table name", record_id: your_id },
    success:
        function (data, textStatus, xmlHttpRequest)
        {
            if(data.result==true) 
                if(confirm('Continue?')) 
                {
                    // continue with save 
                }
        }
});