This code seems simple enough on the surface but I am trying to display a message when no records are present in datalist.
I have this on markup:
<asp:DataList ID="DataList1" runat="server" CellPadding="4"
DataSourceID="SqlDataSource1"
Font-Bold="False" OnSelected="SqlDataSource1_Selected" Font-Names="Verdana"
Font-Size="Small" RepeatColumns="2"
RepeatDirection="Horizontal" Width="100%" ForeColor="#333333">
<AlternatingItemStyle BackColor="White" ForeColor="#284775" />
...
...
</asp:DataList>
<asp:label CssClass="Treb10Blue" ID="lblMsg" runat="server"></asp:Label>
Then on codebehind, I have this:
Protected Sub SqlDataSource1_Selected(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceStatusEventArgs) Handles SqlDataSource1.Selected
If e.AffectedRows = 0 Then
lblMsg.Visible = True
lblMsg.Text = "No records found"
Else
lblMsg.Text = ""
End If
End Sub
I am not getting any errors but the message is not displaying.
Any ideas what could be wrong?