views:

780

answers:

1

Hi,

I conditionally hide/show panels in a DetailsView... I want to also hide/show the DetailsView row/field that the panel is contained in because it is currently displaying empty rows when the panels are hidden?

ASCX:

<asp:DetailsView>
<asp:TemplateField>
  <ItemTemplate>
    <asp:panel runat="server" ID="pnlHideShow" OnInit="OnInit_Panel">  
...

CodeBehind:

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;
    ...
  }
  ...
}

Hope I am not a candidate for "worse-than-failure" ;)

+1  A: 

Something like:

pnl.Visible = (some condition);
pnl.Parent.Visible = true;  // you may have to go pnl.Parent.Parent.Parent.Visible... try stepping through debug
davewasthere