Repeater ITEM TEMPLATE颜色

时间:2013-10-08 01:32:19

标签: asp.net

在转发器项目模板中,我可以制作备用的颜色difFerent.ie..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>

2 个答案:

答案 0 :(得分: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

答案 1 :(得分: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>