I am using a WebForms GridView control. When a user clicks “Update” on a row, I want to check the values they entered against some other records.
From that, if I return true, I’d like to display a confirm dialog asking the user if they’d like to continue with their update.
A javascript confirm dialog probably won’t work because I don’t always want to show this dialog, only when the values entered meet a certain condition.
Any suggestions?
I would suggest using the
RowDataBoundevent to check for those conditions and add the confirmation dialog where needed.EDIT : Compare dates and show a confirmation if they’re different
See this jsFiddle for a demonstration.
And here’s the code for the
datesclass used for the comparison (link):In the
RowDataBoundevent of theGridView, assign theonchangefunction for each row:jQuery Confirmation Dialog
If you need something more flexible than a regular JavaScript confirm dialog, you can change the above to use the jQuery UI Dialog as a confirmation instead.