Asp nestede repeaters, problemer med at hide a asp linkbutton hvis label er tom.
Jeg prøver at skjule en linkbutton som ligger inde i en nestede repeater.min asp kode, jeg har gjort den lidt kortere men der er mere data i den, derfor jeg bruger repeaters med xml data.
<asp:Repeater ID="Repeater4" runat="server" DataSourceID="XmlDataSourceDriverStepsResponse">
<ItemTemplate>
<asp:Repeater ID="childRepeaterToday" runat="server" OnItemCommand="_startDay_ItemCommand" EnableViewState="true" DataSource='<%# XPathSelect ("Step") %>'>
<ItemTemplate>
<asp:LinkButton data-text-loading="Loading..." ID="startDay" runat="server" CssClass="myButton" data-style="expand-down" CommandName="StartDay" Style="text-decoration: none; color: black;" CommandArgument=' <%#XPath ("StepTypeText")%>'>
<asp:label Text='<%#XPath ("StepTypeText")%>' id="lblMessage" runat="server"/>
</asp:LinkButton>
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:Repeater>
C#
protected void Repeater4_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
foreach (RepeaterItem item in Repeater4.Items)
{
if (item.ItemType == ListItemType.AlternatingItem || item.ItemType == ListItemType.Item)
{
Repeater childRpr = (Repeater)item.FindControl("childRepeaterToday");
}
}
}
protected void innerRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
{
foreach (RepeaterItem item in childRepeaterToday.Items)
{
Label lblMessage = item.FindControl("lblMessage") as Label;
if (string.IsNullOrEmpty(lblMessage.ToString()))
{
//lblMessage.Text = "test";
LinkButton lnkBtnTags = (LinkButton)item.FindControl("startDay");
lnkBtnTags.Visible = false;
}
}
}
}