What if SQL DataSource returns null or nothing
I had a SQLDataSource and wanted to show a message that nothing matches the search if the source didn’t return any rows of data.
here’s how..
add to the sqldatasource
<asp:SqlDataSource ID="SqlDataSource1" OnSelected="SqlDataSource1_Selected" ...
and then in the code behind.
Protected Sub SqlDataSource1_Selected(ByVal sender As Object, ByVal e As SqlDataSourceStatusEventArgs)
If e.AffectedRows < 1 Then
lblnonefound.Text = "No matches found, Please try again"
lblnonefound.Visible = True
Else
lblnonefound.Text = ""
lblnonefound.Visible = False
End If
End Sub
