title: Hide Panel in a datalist with Linkbutton and C# and javascript
body: <p>I'm a new programmer, so any help or suggestions would be appreciated.</p>
  
  <p>I have a datalist containing a link button that displays a row of data.  The linkbutton, when clicked, should unhide a panel that contains a datalist (also containing a linkbutton), that displays more detailed information.  The problem that I am having is that when I click on the summary linkbutton it will not fire the javascript to hide or show the details panel.  I'm not getting any exceptions, my program builds and runs, so I'm not sure why the javascript won't fire. FYI, the DBClass and DbClass object are in-house classes, they work fine. Here is my code:</p>
  
  <pre><code>using System;
  usingSystem.Collections;
  usingSystem.Configuration;
  usingSystem.Data;
  usingSystem.Linq;
  usingSystem.Web;
  usingSystem.Web.Security;
  usingSystem.Web.UI;
  usingSystem.Web.UI.HtmlControls;
  usingSystem.Web.UI.WebControls;
  usingSystem.Web.UI.WebControls.WebParts;
  usingSystem.Xml.Linq;
  usingDBClass;
  
  
  namespaceTimeLogging.pages
  {
    publicpartialclassdbEntry:System.Web.UI.Page
    {
      QueryClassqc=newQueryClass();
  
    protectedvoidPage_Load(objectsender,EventArgse)
    {
      bindDlReportProjSum_devSummary();
    }
  
    //getsthelinkbuttonattributefortheemployeeidsothatitcanbeboundtothedatalist
  protectedvoiddlReportProjSum_devSummary_OnItemDataBound(objectsender,DataListItemEventArgse)
  {
    if(e.Item.ItemType == ListItemType.Item 
      || e.Item.ItemType == ListItemType.AlternatingItem)
    {
      DataListnestedDataList=(DataList)e.Item.FindControl("dlReportProjSum_devDetail");
      LinkButtonlinkbtn=(LinkButton)e.Item.FindControl("lbReportProjSum_devSummary");
      bindDlReportProjSum_devDetail(nestedDataList,linkbtn.Attributes["empid"]);
      //Panelpan=(Panel)e.Item.FindControl("panReportProjSum_devDetail");
    }
  }
  
  //hidesthedevedetailpanelonlinkbutttonclick
  protectedvoiddlReportProjSum_devSummary_OnItemCommand(objectsender,DataListCommandEventArgse){
  
  LinkButtonlb=(LinkButton)e.Item.FindControl("lbReportProjSum_devSummary");
  Panelpan=(Panel)e.Item.FindControl("panReportProjSum_devDetail");
  }
  
  //thedatalistthatshowsasummaryofeachemployeewhohasworkedonaproject
  protectedvoidbindDlReportProjSum_devSummary(){
  DbClassdb=newDbClass();
  DataTabledt=newDataTable();
  stringsqlString=@"selectname,empid,sum(actualtime)astotal
  fromTime_logging_vwProjDevDetail
  whereprojid=1
  groupbyempid,name";
  db.OpenConnection();
  db.Execute(sqlString);
  dt=db.GetData.Table;
  dlReportProjSum_devSummary.DataSource=dt;
  dlReportProjSum_devSummary.DataBind();
  db.CloseConnection();
  db.Dispose();
  }
  
  
  
  //bindthenesteddatalistinthedevSummaryOnItemDataBoundevent
  privatevoidbindDlReportProjSum_devDetail(DataListdl,stringdevEmpid)
  {
  DbClassdb=newDbClass();
  DataTabledt=newDataTable();
  stringsqlString=string.Format(@"selectDAYOF,ESTTIME,ACTUALTIME,NOTES,TASK
  fromtime_logging_resourceswhere
  projid=1andempid={0}",devEmpid);
  db.OpenConnection();
  db.Execute(sqlString);
  dt=db.GetData.Table;
  dl.DataSource=dt;
  dl.DataBind();
  
  db.CloseConnection();
  db.Dispose();
  }
  
  
  
  ////whenthedeveloperssummaryoftotalhoursonaprojectisclicked
  protectedvoidlbReportProjSum_devSummary_Click(objectsender,EventArgse)
  {
  ClientScript.RegisterStartupScript(GetType(),"Javascript","HidePanel()",true);
  
  }
  
  }
  }
  
  ASPXpage////////////////////////////////////////////////////////////////////////////////
  
  
  &lt;%@PageLanguage="C#"AutoEventWireup="true"CodeBehind="dbEntry.aspx.cs"Inherits="TimeLogging.pages.dbEntry"%&gt;
  
  &lt;%@RegisterAssembly="AjaxControlToolkit"Namespace="AjaxControlToolkit"TagPrefix="asp"%&gt;
  
  &lt;!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;htmlxmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;headrunat="server"&gt;
  &lt;title&gt;UntitledPage&lt;/title&gt;
  &lt;linkhref="../css/Main.css"rel="stylesheet"type="text/css"/&gt;
  
  &lt;scripttype="text/javascript"language="javascript"&gt;
  functionHidePanel()
  {
  alert("hello");
  varpanel=document.getElementById('panReportProjSum_devDetail');
  if(panel.style.display=='none')
  {
  panel.style.display='block';
  }
  else
  {
  panel.style.display='none';
  }
  }
  &lt;/script&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
  &lt;formid="form1"runat="server"&gt;
  
  &lt;asp:ToolkitScriptManagerID="ToolkitScriptManager1"runat="server"&gt;
  &lt;/asp:ToolkitScriptManager&gt;
  &lt;div&gt;
  &lt;asp:PanelID="panMainReportsHolder"runat="server"&gt;
  
  &lt;asp:DataListID="dlReportProjSum_devSummary"runat="server"RepeatDirection="Vertical"
  ShowFooter="False"ShowHeader="False"OnItemDataBound="dlReportProjSum_devSummary_OnItemDataBound"
  OnItemCommand="dlReportProjSum_devSummary_OnItemCommand"&gt;
  &lt;HeaderTemplate&gt;
  &lt;/HeaderTemplate&gt;
  &lt;ItemTemplate&gt;
  &lt;div&gt;
  &lt;asp:LinkButtonID="lbReportProjSum_devSummary"OnClick="lbReportProjSum_devSummary_Click"
  runat="server"empid='&lt;%#DataBinder.Eval(Container.DataItem,"empid")%&gt;'name='&lt;%#DataBinder.Eval(Container.DataItem,"name")%&gt;'
  total='&lt;%#DataBinder.Eval(Container.DataItem,"total")%&gt;'CssClass="developerSummaryLinkButton"&gt;&lt;%#DataBinder.Eval(Container.DataItem,"name")%&gt;'stotalhoursspentdevelopingtheproject:&lt;%#DataBinder.Eval(Container.DataItem,"total")%&gt;
  
  &lt;/asp:LinkButton&gt;
  
  &lt;asp:PanelID="panReportProjSum_devDetail"runat="server"&gt;
  
  &lt;asp:DataListID="dlReportProjSum_devDetail"runat="server"RepeatDirection="Vertical"
  ShowFooter="False"ShowHeader="False"&gt;
  &lt;HeaderTemplate&gt;
  &lt;/HeaderTemplate&gt;
  &lt;ItemTemplate&gt;
  &lt;div&gt;
  &lt;asp:LinkButtonID="LinkButton1"CssClass="developerDetailLinkButton"runat="server"
  Enabled="false"&gt;Dateworked:&lt;%#DataBinder.Eval(Container.DataItem,"dayof")%&gt;task:&lt;%#DataBinder.Eval(Container.DataItem,"task")%&gt;numberofhoursworked:&lt;%#DataBinder.Eval(Container.DataItem,"actualtime")%&gt;anynotes:&lt;%#DataBinder.Eval(Container.DataItem,"notes")%&gt;
  &lt;/asp:LinkButton&gt;
  &lt;/div&gt;
  &lt;/ItemTemplate&gt;
  &lt;FooterTemplate&gt;
  &lt;/FooterTemplate&gt;
  &lt;/asp:DataList&gt;
  &lt;/asp:Panel&gt;
  
  
  &lt;/div&gt;
  &lt;/ItemTemplate&gt;
  &lt;FooterTemplate&gt;
  &lt;/FooterTemplate&gt;
  &lt;/asp:DataList&gt;
  &lt;/asp:Panel&gt;
  &lt;/div&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>