How can I cancel selecting rows in SqlDataSource
when SelectCommand
timed 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.
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