protected void Reply_OnClick(object sender, EventArgs e) { var linkButton = (LinkButton)sender; var replyPanel = (Panel)WebFormHelper.FindControlRecursive(linkButton.Parent, "ReplyPanel"); var replyPanels = WebFormHelper.FindControlsRecursive(ItemsList, "ReplyPanel"); foreach (var panel in replyPanels) { panel.Visible = false; } ReplyToCommentID = long.Parse(linkButton.CommandArgument); if (replyPanel != null) { replyPanel.Visible = true; } }