I am having a problem and had been searching the web and couldn't find anything that will help me.
this is my problem.
Im working in WinForm , c#
I have a grid where is a Column of type **GridViewDateTimeColumn**.
When the user update a row I check it in the event **RowValidating** and if I get a repeated date or other error I show the user a message and I do **e.cancel = true** to not validate the row.
But then If I press ESC. I cannot cancel all the changes like it usually does before
Any idea how to do it?
Here is my code:
private
void
grdPirteyMenahel_RowValidating(
object
sender, RowValidatingEventArgs e)
{
try
{
Cursor.Current = Cursors.WaitCursor;
if
(e.Row !=
null
)
{
//Generate a service to connect to DB
var factory =
new
MezumanimChannelFactory<IKerenService>(ServiceConsts.SERVICE_KEREN);
var service = factory.CreateChannel();
string
sError =
string
.Empty;
//here I call a SP in the database that check if the dates are correct (column of dates are call it "MiTaarich" and "AdTaarich".
//The SP return a String with the error, if there is no error it will return and empty string
sError = GetErrorPirteySacharMenahel(Convert.ToDateTime(e.Row.Cells[
"MiTaarich"
].Value), Convert.ToDateTime(e.Row.Cells[
"AdTaarich"
].Value), Convert.ToInt32(e.Row.Cells[
"Kod"
].Value));
if
(sError !=
string
.Empty)
{
e.Cancel =
true
;
RadMessageBoxHelper.Alert(sError);
}
}
}
catch
(Exception ex)
{
Elad.Mezumanim.Client.Utils.Log.LogUtil.write(ex);
e.Cancel =
true
;
RadMessageBoxHelper.Alert(Messages.DataDisplayError,
this
);
}
finally
{
Cursor.Current = Cursors.Default;
}
}
I also tried adding this code when i get the error:
DataTable dt = (grdPirteyMenahel.DataSource
as
DataTable);
dt.RejectChanges();
But this recover the value of date as it was before (what is good) but doesn't let me get out of the row when I press ESC
Any idea how to solve it?
thank you very much
best regards
Iair