我有条不紊地隐藏/显示DetailsView中的面板... 我还想隐藏/显示包含面板的DetailsView行/字段 因为当隐藏面板时它当前显示空行?
ASCX:
<asp:DetailsView>
<asp:TemplateField>
<ItemTemplate>
<asp:panel runat="server" ID="pnlHideShow" OnInit="OnInit_Panel">
...
代码隐藏:
protected void OnInit_Panel(object sender, EventArgs e)
{
Panel pnl = (Panel) sender;
pnl.Visible = false;
switch (pnl.ID)
{
default:
break;
case "pnlHideShow":
pnl.Visible = (some condition);
//How to hide/show DetailsView item containing this panel?
break;
...
}
...
}
希望我不是“worse-than-failure”的候选人;)
答案 0 :(得分:4)
类似的东西:
pnl.Visible = (some condition);
pnl.Parent.Visible = true; // you may have to go pnl.Parent.Parent.Parent.Visible... try stepping through debug