0

在中继器项目模板中,我可以使交替的颜色不同吗?即..1 蓝色下一个白色,下一个蓝色,白色......就像那样。

在这个项目模板中,我有一个标题部门和细节部门。我希望标题部门有像网格视图一样的替代颜色。有可能..?谢谢

    <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="Groove" BackColor="#00D9D9">

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


   <%# DataBinder.Eval(Container.DataItem, "StartDate")%
   <%# DataBinder.Eval(Container.DataItem, "Renewal")%>
  </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

2 回答 2

0

您可以使用AlternatingItemTemplate指定交替项目的格式。这是一个简单的例子:

<asp:Repeater id="Repeater1" runat="server">
  <HeaderTemplate>
     <table border="1">
  </HeaderTemplate>
  <AlternatingItemTemplate>
     <tr>
        <td style="background-color:Blue">
           <b><%# Container.DataItem %></b> 
        </td>
     </tr>
  </AlternatingItemTemplate>
  <ItemTemplate>
     <tr>
        <td style="background-color:White"> 
           <%# Container.DataItem %> 
        </td>
     </tr>
  </ItemTemplate>
  <FooterTemplate>
     </table>
  </FooterTemplate>
</asp:Repeater>

有关详细信息,请参阅:http: //msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.repeater.alternatingitemtemplate.aspx

于 2013-10-08T02:54:08.463 回答
0

            <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="Groove" BackColor="#00D9D9">

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


                    <%# DataBinder.Eval(Container.DataItem, "StartDate")%>
                    <%# DataBinder.Eval(Container.DataItem, "Renewal")%>
                </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>
        <AlternatingItemTemplate>
            <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="Groove" BackColor="#f0e68c">

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


                    <%# DataBinder.Eval(Container.DataItem, "StartDate")%>
                    <%# DataBinder.Eval(Container.DataItem, "Renewal")%>
                </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>
        </AlternatingItemTemplate>



    </asp:Repeater>
于 2013-10-08T03:43:34.037 回答