我试图将多个类添加到ListView中的LinkButton。
这有效:
<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>
最佳答案
试试这个对我有用
<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>