0

我的数据库中有一个 1 行表。该行称为“活动”,其值为 1(活动)或 2(非活动)

我想检查数据库,如果站点处于活动状态,请将标签文本设置为“站点当前处于活动状态”,如果所述字段为“0”,则将标签文本设置为“站点当前处于非活动状态”

我知道 ti 看起来很基本,但我很难过。我试过中继器,但我不知道如何在这种情况下操作它

4

2 回答 2

0

您可以在 formview 控件中尝试这样的操作:

<asp:TextBox ID="TextBox1" runat="server"
    Text='<%#Convert.ToBoolean( Eval("Active"))?"Site Is currently Inactive":"Site Is currently Active"%>'
    ></asp:TextBox>

或者

<asp:TextBox ID="TextBox2" runat="server"
    Text='<%# Eval("Active").ToString().Equals("True")?"Site Is currently Inactive":"Site Is currently Active"%>'
    ></asp:TextBox>
于 2012-05-30T06:00:07.647 回答
0

不断进行故障排除......这终于奏效了

Private Sub Repeater1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles Repeater1.ItemDataBound
    Dim MyLabel As Label = e.Item.FindControl("SiteStatus")

    If MyLabel.Text = "1" Then
        MyLabel.Text = "SITE IS CURRENTLY ACTIVE"
        MyLabel.CssClass = "Green"
    End If
End Sub
于 2012-05-30T05:05:57.610 回答