0

在中继器中,当我单击row1它时,它正在展开,当我单击 时row2,它row1正在折叠并row2正在展开。

但是,当我单击 row1(类标题)时,它正在扩展,但是当我再次单击 row1 时,它也必须折叠。那是行不通的。

    <style>
   .header { font-size: larger; font-weight: bold; cursor: hand; cursor:pointer;
       background-color:#cccccc; font-family: Verdana; }
   .details { display:none; visibility:hidden; 
         font-family: Verdana; }
    </style>
 <SCRIPT>
     function ToggleDisplay(id) {
    var allDetails = document.getElementsByClassName('details');
    var detaisToShow = document.getElementById('d' + id);
    for(var i=0; i<allDetails.length; i++){
        allDetails[i].style.display = 'none';
        allDetails[i].style.visibility = 'hidden';
    }
    detaisToShow.style.display = 'block';
    detaisToShow.style.visibility = 'visible';
    }

 </SCRIPT>
<style>
    .header { font-size: larger; font-weight: bold; cursor: hand; cursor:pointer;
       background-color:#cccccc; font-family: Verdana; }
  .details { display:none; visibility:hidden; 
         font-family: Verdana; }
</style>

    &nbsp;<div style="overflow: scroll; overflow-x: hidden; overflow-y: auto;background-color:gray;  height: 500px; width: 895px">

<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">

         <ItemTemplate>


 <div id='h<%# DataBinder.Eval(Container, "ItemIndex") %>' class="header"
      onclick='ToggleDisplay(<%# DataBinder.Eval(Container, "ItemIndex") %>);' style="border- style: none;">
     <asp:Panel ID="Panel3" runat="server" Height="30px" BorderStyle="None" BackColor="#79FFFF">

    <%# DataBinder.Eval(Container.DataItem, "License")%> 
   <%# DataBinder.Eval(Container.DataItem, "Name")%>

  <%# DataBinder.Eval(Container.DataItem," Date")%>
  </asp:Panel> 
 </div>

<div id='d<%# DataBinder.Eval(Container, "ItemIndex") %>' class="details">

  <asp:Panel ID="Panel2" runat="server" Height="195px" BackColor="Gray" Font-Bold="False"  ForeColor="Maroon">
  <br />
      <asp:Label ID="Label1" runat="server" Text="LicenseID"></asp:Label>&nbsp;&nbsp;&nbsp;&nbsp;

                <asp:TextBox ID="TextBox1" runat="server" Text='<%# DataBinder.Eval  (Container.DataItem,"LicenseID") %>' Enabled="False" BackColor="Gray"   BorderStyle="None"></asp:TextBox>
      <asp:Label ID="Label2" runat="server" Text="License Name"></asp:Label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <asp:TextBox ID="TextBox2" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"LicenseName")%>' Enabled="false" BackColor="Gray" BorderStyle="None"></asp:TextBox>

            </asp:Panel>

 </div>

        </ItemTemplate>
4

0 回答 0