views:

31

answers:

1

I am validating user input in the CellValidating event of a DataGridView control and when the user inputs an illegal value, I show a messagebox. The problem is that the CellValidating event fires twice and hence the messagebox appears twice. I tried experimenting with various things and it appears to happen only when the messagebox is shown in the event. How can I avoid this problem?

A: 

you can try this: declare a boolean instance varibale in your page class and set it to true on pageload. then check if it's true in your validation code. If it's true then run your validation code and set it to false. if it's already false do not execute your validation code

sirmak
Note, I added winforms tag. Sorry if you misinterpreted the question.
John_Sheares