Inside the if set ExceptionHandled to true.
Up vote 2 down vote favorite share g+ share fb share tw.
I’m getting this error over and over again. Loading the data into the GridView works, but when I want to delete a row I'm getting that error. '> C# codebehind - I'm not really deleting the row from the database but it's a test: protected void OrdersGridView_RowDeleted(object sender, System.Web.UI.WebControls.
GridViewDeletedEventArgs e) { if (e. Exception! = null) { lblStatus.
Text = e.Exception.ToString(); } else { string sValue = ((HiddenField)OrdersGridView.SelectedRow. Cells1. FindControl("HiddenField1")).
Value; lblStatus. Text = sValue; } } But after clicking, I get a bigass yellow page with the next error: The GridView 'OrdersGridView' fired event RowDeleting which wasn't handled. C# gridview link|improve this question edited Aug 23 '10 at 0:37Timwi20.7k23085 asked Aug 23 '10 at 0:25Janis6317 50% accept rate.
Inside the if, set ExceptionHandled to true: if (e. Exception! = null) { lblStatus.
Text = e.Exception.ToString(); e. ExceptionHandled = true; }.
Ok, but that doesn't help me with the error – Janis Aug 23 '10 at 1:08.
It looks like you are handling the "onrowdeleted" event, not the "RowDeleting" event in your markup, change: onrowdeleted="OrdersGridView_RowDeleted" to RowDeleting="OrdersGridView_RowDeleting" Look a the docs for this event: you will also see that your handler's signature will need to change: msdn.microsoft.com/en-us/library/system.... your new handler will look someting like this: protected void OrdersGridView_RowDeleting(object sender, System.Web.UI.WebControls. GridViewDeleteEventArgs e) { if (e. Exception!
= null) { lblStatus. Text = e.Exception.ToString(); } else { string sValue = ((HiddenField)OrdersGridView.SelectedRow. Cells1.
FindControl("HiddenField1")). Value; lblStatus. Text = sValue; } } the RowDeleting event happens, then the onrowdeleted event.
The RowDeleting probally lets you Cancel the event.
I've changed it but it didn't work, I got the same error But I had the RowDeleting="OrdersGridView_RowDeleting" AND the RowDeleted="OrdersGridView_RowDeleted" at first and after reading about rowdeleting , I skipped that one cause I don't want to ask the user if he/she is okay with deleting the row, I just want to delete it. – Janis Aug 23 '10 at 0:49 The Grid View binds to data, and allows someone to delete a record: This event lets you tell the grid what how to do that. This error is saying "you have asked me to delete a record, but you have not told me how.
" the RowDeleted is slated after the delete happens. Can you indicate how it did not work (same error, different error, lblStatus. Text or sValue did not have the expected value)?
Thanks – brian chandley Aug 23 '10 at 1:14 its the same error on the same yellow colored error page , the error doesn't even show on my lblstatus label. Coould it somehow have something to do with me publishing the altered files to my host. I don't have the error on my local space.
– Janis Aug 23 '10 at 1:35 The error does not happen locally? That is odd. Does it behave as expected locally?.
My first thought would be to check that both the aspx and the dlls have been published properly. – brian chandley Aug 23 '10 at 1:53 I only upload the aspx and the aspx.cs file, I didn't create dlls ... yet – Janis Aug 23 '10 at 2:03.
Having a Delete button, or even a regular button in a GridView with a CommandName of delete, will automatically try to fire OnRowDeleting. You can just add it in to make things happy, but don't have it do anything so it doesn't affect the behavior of your delete. You could add OnRowDeleting to your GridView: And then in your CodeBehind add: void OrdersGridView_RowDeleting (object sender, GridViewDeleteEventArgs e) { }.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.