Click here to Skip to main content
15,885,758 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi Folks,
When I change the datagrid view cell value and delete some primary key value. there is a popup that says "To replace this default dialog please handle the dataError Event.". I am not sure where should I handle this error. find no place to put try catch in the code.
Please suggest where should I place the try catch to handle such an exception on datagrid view
Regards
Posted

C#
void InitializeComponent() {
   // ... //

   this.DataGridView.DataError += this.DataGridView_DataError;
}

void DataGridView_DataError(object sender, DataGridViewDataErrorEventArgs e) {
   e.ThrowException = false;
}



Use this code u will capture the error then perform according to that error.
 
Share this answer
 
Comments
bbirajdar 10-Nov-13 21:32pm    
Thank you for providing code for a question posted more than 3 years ago... Dont you thinks its too late ?
philtvr 24-Apr-15 9:59am    
Thanks for adding the answer, helped with my problem
can you send me the code block to understand the issue?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900