在ListView中向LinkBut​​ton添加多个动态类

时间:2014-02-05 23:13:10

标签: asp.net css listview

我正在尝试将多个类添加到ListView中的LinkBut​​ton。

这有效:

<asp:LinkButton ID="lbAttendee" runat="server" CssClass='CheckedInTrue attendee'>

这有效:

<asp:LinkButton ID="lbAttendee" runat="server" CssClass='<%#Eval("CheckedIn") %>'>

<asp:LinkButton ID="lbAttendee" runat="server" CssClass='CheckedIn<%#Eval("CheckedIn") %> attendee'>

当我以第三种方式进行时,该类按字面意思呈现,如下所示:

<a id="lvAttendees_ctrl1_lbAttendee" class="CheckedIn<%#Eval("CheckedIn") %> attendee" href="javascript:__doPostBack('lvAttendees$ctrl1$lbAttendee','')">
            <span style="display:none;">2</span>
                <p class="studentName">Joseph Conrad</p>
                <p class="studentID">13526861</p>
            </a>

1 个答案:

答案 0 :(得分:0)

试试这个对我有用

<a id="lvAttendees_ctrl1_lbAttendee" class='<%# String.Format("CheckedIn {0} attendee", Eval("CheckedIn")) %>' href="javascript:__doPostBack('lvAttendees$ctrl1$lbAttendee','')">
                <span style="display:none;">2</span>
                    <p class="studentName">Joseph Conrad</p>
                    <p class="studentID">13526861</p>
                </a>