Advertisement

02.28.2008 at 08:40PM PST, ID: 23202921
[x]
Attachment Details

How do I handle gridview delete event

Asked by rufassa in Programming for ASP.NET, .NET, Microsoft Visual C#.Net

Tags: C#, 3.5

Why is my event handler class not fireing?
I have the following:

ASPX:
<asp:GridView ID="vwPatient" runat="server" OnRowDeleted="GridView_RowDeleted" AutoGenerateDeleteButton="True">

Code Behind:
protected void GridView_RowDeleted(Object src, GridViewDeletedEventArgs e)
{
            if (e.Exception == null)
            {
                if (e.AffectedRows == 1)
                {
                    lblInfoPatient.Visible = true;
                    lblInfoPatient.Text = "Record deleted successfully.";
                }
                else
                {
                    lblInfoPatient.Visible = true;
                    lblInfoPatient.Text = "An error occurred during the delete operation.";
                }
            }
            else
            {
                lblInfoPatient.Visible = true;
                lblInfoPatient.Text = e.Exception.Message;
                e.ExceptionHandled = true;
            }
}
       
But yet I receive the following error:

The GridView 'vwPatient' fired event RowDeleting which wasn't handled.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace:


[HttpException (0x80004005): The GridView 'vwPatient' fired event RowDeleting which wasn't handled.]
   System.Web.UI.WebControls.GridView.OnRowDeleting(GridViewDeleteEventArgs e) +1494719
   System.Web.UI.WebControls.GridView.HandleDelete(GridViewRow row, Int32 rowIndex) +604
   System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +1134
   System.Web.UI.WebControls.GridView.RaisePostBackEvent(String eventArgument) +199
   System.Web.UI.WebControls.GridView.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +177
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746

Start Free Trial
[+][-]02.28.2008 at 09:42PM PST, ID: 21011175

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.28.2008 at 11:40PM PST, ID: 21011581

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.29.2008 at 03:33PM PST, ID: 21018654

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.01.2008 at 02:10AM PST, ID: 21020976

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Programming for ASP.NET, .NET, Microsoft Visual C#.Net
Tags: C#, 3.5
Sign Up Now!
Solution Provided By: digitalZo
Participating Experts: 3
Solution Grade: B
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628