인트라넷 웹 응용 프로그램을 개발 중입니다. 저는 직원 프로필, 교육 과정, 회사 간략한 퀴즈 및 제출 된 아이디어 및 제안에 관한 4 개의 테이블을 보여주는 사용자 프로필에 대해 작업하고 있습니다.Repeater 컨트롤 안에 데이터가없는 경우 메시지를 표시하는 방법은 무엇입니까?
직원에게 제안이 없다면 사용자에게 제안이 없다는 것을 알리지 않고 헤더가있는 표를 표시하는 대신 표 안에 (제안 사항이 없습니다)와 같은 메시지가 표시됩니다. 그렇게하는 방법?
내 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>
체크 아웃이 질문에 대한 답 : http://stackoverflow.com/questions/6579814/render-empty-repeater –