Home All Groups Group Topic Archive Search About

How to Catch exception for GridView control?

Author
28 Jan 2006 2:13 PM
kai
Hi,
  I placed a Gridview control on a ASP.NET 2.0 page and enabled the
"Delete", "Edit" . I want to do "Try Catch" on "Delete" and "Edit" button in
the GridView but don't find the place to put the code. Please help.

Thanks!

Kai

Author
28 Jan 2006 7:09 PM
Phillip Williams
You will have to handle the Page level Error event:
http://msdn2.microsoft.com/en-us/library/ed577840.aspx
Show quoteHide quote
"kai" wrote:

> Hi,
>   I placed a Gridview control on a ASP.NET 2.0 page and enabled the
> "Delete", "Edit" . I want to do "Try Catch" on "Delete" and "Edit" button in
> the GridView but don't find the place to put the code. Please help.
>
> Thanks!
>
> Kai
>
>
>
Author
28 Jan 2006 11:04 PM
kai
Phillip ,
Thanks for your help.
I went to the > http://msdn2.microsoft.com/en-us/library/ed577840.aspx

and use the code:

private void Page_Error(object sender, EventArgs e)
{
    Response.Write("An application error has been logged.");
    ApplicationSpecificErrorLogger(Server.GetLastError().Message);
    Server.ClearError();
}

I found error for not recogonizing "ApplicationSpecificErrorLogger". I
looked it in help file and not find the class.

What I did is using GridView to display "Phone Number", and a front user
can edit the number. I setup phone number datatype vchar(20). When user
enter longer than 20 characters, error message will show. Try/Catch cannot
catch the exception.

Kai


Show quoteHide quote
"Phillip Williams" <WEBSWAPP@newsgroups.nospam> wrote in message
news:0BEA7BC2-9CB9-4A2A-8B48-4FB5E981433B@microsoft.com...
> You will have to handle the Page level Error event:
> http://msdn2.microsoft.com/en-us/library/ed577840.aspx
> --
> HTH,
> Phillip Williams
> http://www.societopia.net
> http://www.webswapp.com
>
>
> "kai" wrote:
>
>> Hi,
>>   I placed a Gridview control on a ASP.NET 2.0 page and enabled the
>> "Delete", "Edit" . I want to do "Try Catch" on "Delete" and "Edit" button
>> in
>> the GridView but don't find the place to put the code. Please help.
>>
>> Thanks!
>>
>> Kai
>>
>>
>>
Author
29 Jan 2006 12:29 AM
Phillip Williams
The function named ApplicationSpecificErrorLogger is not part of the .net
framework.  If you had read the "Compiling the Code" section of that article,
it reads:
"This example requires: An ASP.NET Web page. An error-logging function that
is specific to your application."

For the purpose of your testing, you could have simply written:

Response.Write (Server.GetLastError().Message);

Show quoteHide quote
"kai" wrote:

> Phillip ,
>  Thanks for your help.
> I went to the > http://msdn2.microsoft.com/en-us/library/ed577840.aspx
>
> and use the code:
>
> private void Page_Error(object sender, EventArgs e)
> {
>     Response.Write("An application error has been logged.");
>     ApplicationSpecificErrorLogger(Server.GetLastError().Message);
>     Server.ClearError();
> }
>
> I found error for not recogonizing "ApplicationSpecificErrorLogger". I
> looked it in help file and not find the class.
>
> What I did is using GridView to display "Phone Number", and a front user
> can edit the number. I setup phone number datatype vchar(20). When user
> enter longer than 20 characters, error message will show. Try/Catch cannot
> catch the exception.
>
> Kai
>
>
> "Phillip Williams" <WEBSWAPP@newsgroups.nospam> wrote in message
> news:0BEA7BC2-9CB9-4A2A-8B48-4FB5E981433B@microsoft.com...
> > You will have to handle the Page level Error event:
> > http://msdn2.microsoft.com/en-us/library/ed577840.aspx
> > --
> > HTH,
> > Phillip Williams
> > http://www.societopia.net
> > http://www.webswapp.com
> >
> >
> > "kai" wrote:
> >
> >> Hi,
> >>   I placed a Gridview control on a ASP.NET 2.0 page and enabled the
> >> "Delete", "Edit" . I want to do "Try Catch" on "Delete" and "Edit" button
> >> in
> >> the GridView but don't find the place to put the code. Please help.
> >>
> >> Thanks!
> >>
> >> Kai
> >>
> >>
> >>
>
>
>
Author
29 Jan 2006 4:03 AM
kai
Phillip,
  Thanks.

Kai
Show quoteHide quote
"Phillip Williams" <WEBSWAPP@newsgroups.nospam> wrote in message
news:1429C506-8A12-4D32-A536-914A519CFE42@microsoft.com...
> The function named ApplicationSpecificErrorLogger is not part of the .net
> framework.  If you had read the "Compiling the Code" section of that
> article,
> it reads:
> "This example requires: An ASP.NET Web page. An error-logging function
> that
> is specific to your application."
>
> For the purpose of your testing, you could have simply written:
>
> Response.Write (Server.GetLastError().Message);
>
> --
> HTH,
> Phillip Williams
> http://www.societopia.net
> http://www.webswapp.com
>
>
> "kai" wrote:
>
>> Phillip ,
>>  Thanks for your help.
>> I went to the > http://msdn2.microsoft.com/en-us/library/ed577840.aspx
>>
>> and use the code:
>>
>> private void Page_Error(object sender, EventArgs e)
>> {
>>     Response.Write("An application error has been logged.");
>>     ApplicationSpecificErrorLogger(Server.GetLastError().Message);
>>     Server.ClearError();
>> }
>>
>> I found error for not recogonizing "ApplicationSpecificErrorLogger". I
>> looked it in help file and not find the class.
>>
>> What I did is using GridView to display "Phone Number", and a front user
>> can edit the number. I setup phone number datatype vchar(20). When user
>> enter longer than 20 characters, error message will show. Try/Catch
>> cannot
>> catch the exception.
>>
>> Kai
>>
>>
>> "Phillip Williams" <WEBSWAPP@newsgroups.nospam> wrote in message
>> news:0BEA7BC2-9CB9-4A2A-8B48-4FB5E981433B@microsoft.com...
>> > You will have to handle the Page level Error event:
>> > http://msdn2.microsoft.com/en-us/library/ed577840.aspx
>> > --
>> > HTH,
>> > Phillip Williams
>> > http://www.societopia.net
>> > http://www.webswapp.com
>> >
>> >
>> > "kai" wrote:
>> >
>> >> Hi,
>> >>   I placed a Gridview control on a ASP.NET 2.0 page and enabled the
>> >> "Delete", "Edit" . I want to do "Try Catch" on "Delete" and "Edit"
>> >> button
>> >> in
>> >> the GridView but don't find the place to put the code. Please help.
>> >>
>> >> Thanks!
>> >>
>> >> Kai
>> >>
>> >>
>> >>
>>
>>
>>