Hi Imar,
Thank you for your reply and excellent explanation. I think I may be getting the concept, but just unable to get the code to work. I tried it both ways, didn't get any errors, but the if/then statements didn't seem to fire. Here's the full code I added with your suggestions:
<h1 id="pgttl" title="Trial Officials">Trial Officials</h1>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:apdtConnect %>"
SelectCommand="SELECT [StateID], [State] FROM [tblDDownStates] ORDER BY [State]">
</asp:SqlDataSource>
<h2>
Select Location:
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource1"
DataTextField="State" DataValueField="StateID" BackColor="#FEF9F6">
</asp:DropDownList></h2>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:apdtConnect %>"
SelectCommand="SELECT [DateAdded], [Name], [Address], [City], [State], [Zip], [Phone], [Email], [Level1], [Level2], [Level3], [Rep], [Live] FROM [tblRallyOfficials] WHERE (([State] = @State) AND ([Live] = @Live)) ORDER BY [City], [Name]" EnableCaching="true" DataSourceMode="DataSet" CacheDuration="3800">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="State" PropertyName="SelectedValue"
Type="String" />
<asp:Parameter DefaultValue="True" Name="Live" Type="Boolean" />
</SelectParameters>
</asp:SqlDataSource>
<p><asp:Label ID="lblNoRecords" runat="server"></asp:Label></p>
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource2">
<headertemplate><table border="0" cellpadding="0" cellspacing="0" class="tablelistnb" summary="trial officials table"></headertemplate>
<ItemTemplate>
<tr class="alt">
<td>
<h3><%#(Container.DataItem("Name"))%></h3>
<p><%#(Container.DataItem("Address"))%><br />
<%#Container.DataItem("City")%>, <%#Container.DataItem("State")%><br />
<%#Container.DataItem("Zip")%><br />
<strong>E-mail:</strong> <a href="mailto:<%#Container.DataItem("Email")%>"><%# Container.DataItem("Email")%></a> <a href="mailto:<%#Container.DataItem("Email")%>"><im g src="/assets/img/icons/icon_email.gif" alt="email icon" width="16" height="16" class="icon" /></a></p></td>
<td> </td>
<td><h3>Credentials</h3>
<p><%#checkLevel1(Container.DataItem("Level1"))%>< %#checkLevel2(Container.DataItem("Level2"))%><%#ch eckLevel3(Container.DataItem("Level3"))%><%#checkR ep(Container.DataItem("Rep"))%>
</p></td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr>
<td>
<h3><%#(Container.DataItem("Name"))%></h3>
<p><%#(Container.DataItem("Address"))%><br />
<%#Container.DataItem("City")%>, <%#Container.DataItem("State")%><br />
<%#Container.DataItem("Zip")%><br />
<strong>E-mail:</strong> <a href="mailto:<%#Container.DataItem("Email")%>"><%# Container.DataItem("Email")%></a> <a href="mailto:<%#Container.DataItem("Email")%>"><im g src="/assets/img/icons/icon_email.gif" alt="email icon" width="16" height="16" class="icon" /></a></p></td>
<td> </td>
<td><h3>Credentials</h3>
<p><%#checkLevel1(Container.DataItem("Level1"))%>< %#checkLevel2(Container.DataItem("Level2"))%><%#ch eckLevel3(Container.DataItem("Level3"))%><%#checkR ep(Container.DataItem("Rep"))%>
</p></td>
</tr>
</AlternatingItemTemplate>
<footertemplate></table></footertemplate>
</asp:Repeater>
Protected Sub Repeater1_PreRender(ByVal sender As Object, ByVal e As EventArgs)
If Repeater1.Items.Count = 0 Then
Repeater1.Visible = False
lblNoRecords.Visible = True
Else
Repeater1.Visible = True
lblNoRecords.Visible = False
End If
End Sub
I'm using
VB.NET so I converted it to that. However, it always displays 'no records found' even when the rows are = 0.
It must be something obvious that I'm missing!!!
:)
Christopher