C# 使用数据绑定更改css

C# 使用数据绑定更改css,c#,asp.net,css,data-binding,C#,Asp.net,Css,Data Binding,如您所见,在我的sql数据库中,select命令中有一个类型为Bit的MsgIsNew。如果MsgIsNew字段的值为true,如何将BodyLiteral放在span标记中? 我正在使用asp.net和C。 多谢各位 <asp:Panel ID="Panel2" runat="server" Visible='<%# Eval("MasSender") %>' Width="100%" Wrap="False"> <table style="width:

如您所见,在我的sql数据库中,select命令中有一个类型为Bit的MsgIsNew。如果MsgIsNew字段的值为true,如何将BodyLiteral放在span标记中? 我正在使用asp.net和C。 多谢各位

<asp:Panel ID="Panel2" runat="server" Visible='<%# Eval("MasSender") %>' Width="100%" Wrap="False">
    <table style="width: 100%;">
        <tr>
            <td>
                <asp:Literal ID="BodyLiteral" runat="server" Text='<%# Eval("MsgBody") %>'></asp:Literal>
            </td>
        </tr>            
        <tr>
            <td>
                <asp:Literal ID="DateLiteral" runat="server" Text='<%# DisplayDate(Eval("MsgDate")) %>'></asp:Literal>
            </td>                
        </tr>
    </table>
</asp:Panel>


SelectCommand="SELECT DISTINCT MsgIsNew, MsgBody, MsgDate, FROM Message"
或者更确切地说:

可见光

但您需要确保从数据库返回的值是布尔值,或者通过转换0或1


如果这不是您想要的,请更具体。

您甚至没有说这是什么样的控制。我们需要更多的信息。另外,请删除不必要的代码和正确的格式。我编辑了代码和问题。现在清楚了吗?非常感谢你。
<asp:Panel ID="Panel2" runat="server" Visible='<%# Eval("MasSender") %>' Width="100%" Wrap="False">
<table style="width: 100%;">
    <tr>
        <td>
            <asp:Label runat="server" Visible='<%# Eval("MsgIsNew") %>'>
                <asp:Literal ID="BodyLiteral" runat="server" Text='<%# Eval("MsgBody") %>'></asp:Literal>
            </asp:Label>
        </td>
    </tr>            
    <tr>
        <td>
            <asp:Literal ID="DateLiteral" runat="server" Text='<%# DisplayDate(Eval("MsgDate")) %>'></asp:Literal>
        </td>                
    </tr>
</table>