【发布时间】:2012-03-06 05:18:28
【问题描述】:
我正在开发一个 Intranet Web 应用程序。我现在正在处理用户资料,其中显示了关于员工个人信息、培训课程、公司小测验和他提交的想法和建议的四个表格。
我现在想要的是,如果员工没有建议,则在表格内显示(您没有任何建议)之类的消息,而不是在不告诉用户他没有建议的情况下显示带有标题的表格。 那该怎么做呢?
我的 ASP.NET 代码:
<asp:Repeater ID="Repeater4" runat="server" DataSourceID="SqlDataSource4">
<HeaderTemplate>
<div>
<table border="1">
<thead>
<tr>
<td colspan="3">
<center> <strong>Safety Suggestions</strong> </center>
</td>
</tr>
<tr>
<td>
<center> <strong>Suggestion Title</strong> </center>
</td>
<td>
<center> <strong>Description</strong> </center>
</td>
</tr>
</thead>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<p>
<%# Eval("Title") %>
</p>
</td>
<td>
<p>
<%# Eval("Description") %>
</p>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</div>
</FooterTemplate>
</asp:Repeater>
<asp:SqlDataSource ID="SqlDataSource4" runat="server"
ConnectionString="<%$ ConnectionStrings:testConnectionString %>" SelectCommand="SELECT dbo.SafetySuggestionsLog.Title, dbo.SafetySuggestionsLog.Description, dbo.SafetySuggestionsLog.Username
FROM dbo.SafetySuggestionsLog INNER JOIN
dbo.employee ON dbo.SafetySuggestionsLog.Username = dbo.employee.Username
WHERE (dbo.employee.Username = @Username)">
<SelectParameters>
<asp:Parameter Name="Username" />
</SelectParameters>
</asp:SqlDataSource>
【问题讨论】: