Link to home
Start Free TrialLog in
Avatar of keysersoze
keysersoze

asked on

detailsview missing data after unsucceded insert

I have a DetailsView in insert-mode, this contains some text-boxes with validation and a button with insert-commandname - when i click the button (and validation passes) my InsertMethod of my objectdatasource is fired.

My BLL do also have some validation and if this validation is passed everything is good - but if the validation fails I get a problem. If the BLL-validation fails i catch this up in the Inserted-event of my objectdatasource and gives the user an error-message... but the data filled in the detailsview is gone, not because of missing viewstate I guess but probably because it thinks everything in the insert-method was going well.

How can I catch up the BLL error and keep the userinput in the detailsview?
Avatar of Answer_Me
Answer_Me
Flag of India image

after showing the message box you can try cancelling the validation event.
Avatar of keysersoze
keysersoze

ASKER

I have tried to find a way to do this - but so far I havent found a way to do the trick...
for cancelling the event you need to use eventobj.cancel=true
the inserted-event cant be cancelled?
thats what ..... can't you do validation before this event.
in theory yes - but when the logic is a part of my object it would be double the work to put the logic more places so that is not a solution.
problem solved.

I threw af new applicationerror in my BLL, catching that up in my detailsview ItemUpdated event where I handle ExceptionHandled and KeepInEditMode.
ASKER CERTIFIED SOLUTION
Avatar of Computer101
Computer101
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial