Make use of
SqlDataSource.Selected Event[
^] and one of its arguments
SqlDataSourceStatusEventArgs[
^] such like:
Protected Sub SqlDataSource1_Selected(ByVal sender As Object, ByVal e As SqlDataSourceStatusEventArgs)
If e.AffectedRows = 0 Then
Response.Write("<script language=""javascript""> alert('No match records.');</script>")
End If
End Sub
Last but not least, you should learn
Using Parameters with the SqlDataSource Control[
^] instead of injecting parameters into the sql statement directly owing to potential risks posed by
SQL injection.[
^]