title: How can I display "No Records found" in datalist?
body: <p>This code seems simple enough on the surface but I am trying to display a message when no records are present in datalist.</p>
  
  <p>I have this on markup:</p>
  
  <pre><code>&lt;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"&gt;
     &lt;AlternatingItemStyle BackColor="White" ForeColor="#284775" /&gt;
  ...
  ...
  &lt;/asp:DataList&gt;
  &lt;asp:label CssClass="Treb10Blue" ID="lblMsg" runat="server"&gt;&lt;/asp:Label&gt; 
  </code></pre>
  
  <p>Then on codebehind, I have this:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>I am not getting any errors but the message is not displaying.</p>
  
  <p>Any ideas what could be wrong?</p>