Cancel SqlDataSource selecting rows when SelectCommand timeout

283 views Asked by At

How can I cancel selecting rows in SqlDataSource when SelectCommandtimed out?
I know that I can set CommandTimeout property but I want to Handle error and force Page to continue running when SqlDataSource timed out.

for more information:
in my page, a ListView use SqlDataSource result but this result is not my main content and just recommendation similar list for main content.

1

There are 1 answers

0
Micle On BEST ANSWER

I found the solution: after Selecting timed out, SqlDataSource Selected event start running.

Protected Sub SqlDataSource1_Selected(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceStatusEventArgs) Handles SqlDataSource1.Selected
    If e.Exception is nothing=false andalso e.Exception.InnerException.ToString.ToLower.Contains("timed out") Then
        ListView1.Visible = False
        e.ExceptionHandled = True
    End If
End Sub