I have a repeater in which there's a link and a hidden panel (and some other stuff). I want this link (LinkButton) to show my panel. This is what i've got:
<asp:Repeater id="repeater1" runat="server">
<ItemTemplate>
....
<asp:LinkButton runat="server" ID="lnkTransits" Text="test" CommandName="Transits"/>
<asp:Panel CssClass="transits" id="pnlTransits" runat="server" Visible="False">
....
</asp:Panel>
</ItemTemplate>
</asp:Repeater>
Codebehind (binding the itemcommand in OnInit):
private void FlightList_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item ||
e.Item.ItemType == ListItemType.AlternatingItem)
{
if (e.CommandName == "Transits")
{
var item = e.Item.DataItem;
//var panel = item.FindControl("pnl" + e.CommandName);
//panel.Visible = true;
}
}
}
DataItem is null and every single post says it should be so I've given that idea up. But what i'm hoping instead is that there might be some index value or some way to find "closest" or something that I can use. All i want is to make the panel visible (and hopefully with the same button be able to hide it as well perhaps using the commandargument "hide" "show").
If this is not the way to go to fix this then that's fine, what's the best way?
Thanks in advance