进入if语句后,可是lable的显示值未改变,还是绑定的xml中的值
protected void all_ItemDataBound(object sender, DataListItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
{
Label alb1 = (Label)e.Item.FindControl("alb1");
Label alb2 = (Label)e.Item.FindControl("alb2");
Label acolor = (Label)e.Item.FindControl("acolor");
string all1 = alb1.Text.ToString();
string all2 = alb2.Text.ToString();
string color = acolor.Text.ToString();
if (color == "1")
{
alb1.ForeColor = System.Drawing.Color.Red;
alb2.ForeColor = System.Drawing.Color.Red;
}
if (all1 == "-1.00")
{
alb1.ForeColor = System.Drawing.Color.Red;
alb1.Text = "断线";
alb2.Text = "";
}
else if ((all1 == "0.00") && (all2 == "无"))
{
alb1.ForeColor = System.Drawing.Color.Red;
alb1.Text = "停";
alb2.Text = "";
}
else if ((all1 == "1.00") && (all2 == "无"))
{
alb1.Text = "开";
alb2.Text = "";
}
}
protected void all_ItemDataBound(object sender, DataListItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
{
Label alb1 = (Label)e.Item.FindControl("alb1");
Label alb2 = (Label)e.Item.FindControl("alb2");
Label acolor = (Label)e.Item.FindControl("acolor");
string all1 = alb1.Text.ToString();
string all2 = alb2.Text.ToString();
string color = acolor.Text.ToString();
if (color == "1")
{
alb1.ForeColor = System.Drawing.Color.Red;
alb2.ForeColor = System.Drawing.Color.Red;
}
if (all1 == "-1.00")
{
alb1.ForeColor = System.Drawing.Color.Red;
alb1.Text = "断线";
alb2.Text = "";
}
else if ((all1 == "0.00") && (all2 == "无"))
{
alb1.ForeColor = System.Drawing.Color.Red;
alb1.Text = "停";
alb2.Text = "";
}
else if ((all1 == "1.00") && (all2 == "无"))
{
alb1.Text = "开";
alb2.Text = "";
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货