在VB.net Listview中每隔一行着色?

时间:2011-09-14 18:25:06

标签: asp.net vb.net listview dynamic modalpopup

我一直在谷歌搜索这一天大约一天,我发现的每个帖子都太旧了,Visual Studio无法识别人们发布的一些代码。我有一个动态填充的Listview。为了便于阅读,我真的希望每一行都有阴影,而且无法理解。

我尝试做的所有事情都与Listview中的Modal PopupExtender混淆。它试图遮蔽PopUpBox内部的线条。这是我想要着色的Listviews之一。

<!-- Descriptions -->
<asp:TabPanel ID="tab2"  runat="server" HeaderText="Descriptions">
<HeaderTemplate>Descriptions</HeaderTemplate>
    <ContentTemplate>
        <ul class="info">
        <asp:ListView ID="lvDescriptions" runat="server" DataSourceID="dsMarketingDescriptions" DataKeyNames="MarketingID">
        <ItemTemplate>
            <li>
                <asp:LinkButton ID="ViewDescriptionButton" runat="server"><%#Eval("MarketingTitle")%></asp:LinkButton>
                <asp:Panel ID="ViewDescriptionPanel" runat="server" CssClass="DescModalPopup">                   <div class="PopupHeader" id="PopupHeader">View Description
                <asp:ImageButton ID="CancelDescriptionButton" runat="server" ImageUrl="../../images/exit.png" AlternateText="" Style="float:right;"/>
                </div>
                    <asp:Label ID="Description" runat="server" style="padding:5px;"><%# Eval("MarketingData") %></asp:Label>
                </asp:Panel> 
                <asp:ModalPopupExtender ID="ViewDescriptionModal" runat="server" BackgroundCssClass="modalBackground" DropShadow="false" DynamicServicePath="" Enabled="true" PopupControlID="ViewDescriptionPanel" TargetControlID="ViewDescriptionButton" CancelControlID="CancelDescriptionButton"></asp:ModalPopupExtender>              
            </li>
        </ItemTemplate>
        </asp:ListView>
        </ul>
    </ContentTemplate>
</asp:TabPanel>

enter image description here

1 个答案:

答案 0 :(得分:1)

尝试使用AlternatingItemTemplate为交替项目指定不同的背景颜色。

您是否尝试使用ModalPopupExtender执行此类操作?:

protected void ListView1_ItemDataBound(object sender, ListViewItemEventArgs e)
{
    Panel pnl = e.Item.FindControl("Panel1") as Panel;
    if (pnl != null)
    {
        pnl.BackColor = ListView1.Items.IndexOf(e.Item) % 2 == 1 ? Color.PeachPuff : Color.White;
    }
}