我必须根据复选框动态更改 td 内容。如果未选中复选框,td 将不会采用额外的样式,但如果选中,我的文本必须采用这样的样式:
b style="font-family:Tahoma;font-size:8pt;color:#0f0000;font-weight:normal;">My Text</b
我的代码是这样的:
asp:DataList ID="Inside" runat="server" RepeatColumns="4"
ItemTemplate
<asp:HiddenField ID="FeaID2" runat="server" Value='<%#DataBinder.Eval(Container.DataItem, "FeatureID")%>' >
<td class="checkbox_td"><input disabled="disabled" type="checkbox" <%# int.Parse(DataBinder.Eval(Container.DataItem, "exist").ToString()) > 0 ? "checked" : "" %> /></td>
<td class="text_td">!!!HERE IS MY PROBLEM!!!</td>
/ItemTemplate
/asp:DataList
我使用 C#,那么,如何根据下面的复选框动态地为我调用的 td 内容提供额外的样式(这是我的问题)?
最佳答案
为您的 CSS 添加另一个选择器:-
td.text_td_checked { font-family:Tahoma;font-size:8pt;color:#0f0000;font-weight:normal; }
确保它位于 CSS 中的 text_td 选择器之后。在您的 TD 中:-
<td class="text_td <%# int.Parse(DataBinder.Eval(Container.DataItem, "exist").ToString()) > 0 ? "text_td_checked" : "" %>">!!!Problem Solved!!!</td>
关于c# - 如何动态更改 td 内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1673781/