sqldatasource and connection exception handling

L

Loic Transler

Hi,

In my page, I'm using a gridview and a sqldatasource. I don't know how to
handle the exception that occurs when the database server is unavailable.
I've read that I should use the execption property of the selected event.

But for this exception, the property is null.

How can I handle this exception ?


Thanks,

Loïc
 
M

Michael Hamrah

I tried to replicate the problem and I'm getting the correct behavior-
the exception property is set. Are you sure you're wiring up the
correct event?

//code behind
protected void SqlDataSource1_Selected(object sender,
SqlDataSourceStatusEventArgs e)
{
string s = e.Exception.Message;
}

//page
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="..." SelectCommandType="StoredProcedure"
OnSelected="SqlDataSource1_Selected">
 
L

Loic Transler

Hum... I realized that I was not working on the good sqldatasource... Sorry.

Thank you


Loïc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,196
Latest member
ScottChare

Latest Threads

Top