jak @Saurabh powiedział korzystania <FooterTemplate>
dodać etykietę z określeniem wiadomość we właściwości Text i ustaw jego widoczną właściwość na false:
<FooterTemplate>
<%-- Label used for showing Error Message --%>
<asp:Label ID="ErrorMessage" runat="server" Text="Sorry!!" Visible="false">
</asp:Label>
</FooterTemplate>
Następnie w kodzie źródłowym należy użyć następującej logiki; jeśli nie ma żadnych danych, wyświetli komunikat, w przeciwnym razie pokazują dane w następujący sposób:
protected void Repeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
Repeater rpt = sender as Repeater; // Get the Repeater control object.
// If the Repeater contains no data.
if (rpt != null && rpt.Items.Count < 1)
{
if (e.Item.ItemType == ListItemType.Footer)
{
// Show the Error Label (if no data is present).
Label ErrorMessage = e.Item.FindControl("ErrorMessage") as Label;
if (ErrorMessage != null)
{
ErrorMessage.Visible = true;
}
}
}
}
'' FooterTemplate' HeaderTemplate' i powinny być nadal świadczone nawet jeśli źródło danych zwraca żadnych przedmiotów. Czy te szablony są puste w twoim przypadku? –