遍历所有lable并赋值

for (int i = 1; i <= dt.Rows.Count; i++)
{
(this.FindControl("lblhwmc" + i) as Label).Text = DataHelper.ToString(dt.Rows[i]["cgxm"]);
(this.FindControl("lblpp" + i) as Label).Text = DataHelper.ToString(dt.Rows[i]["pp"]);
(this.FindControl("lblggxh" + i) as Label).Text = DataHelper.ToString(dt.Rows[i]["gg"]);
(this.FindControl("lblysje" + i) as Label).Text = DataHelper.ToString(dt.Rows[i]["dj"]);
(this.FindControl("lblcjj" + i) as Label).Text = DataHelper.ToString(dt.Rows[i]["scdj"]);
(this.FindControl("lblsl" + i) as Label).Text = DataHelper.ToString(dt.Rows[i]["sl"]);
(this.FindControl("lblxj" + i) as Label).Text = DataHelper.ToString(dt.Rows[i]["scjg"]);

}

posted @ 2015-12-23 08:56  开开123  阅读(521)  评论(0编辑  收藏  举报