本人从dataset中获取一些列信息,通过某个字段来判断网页上是否有与之对应的Label控件,然后把这个字段数据赋值给这个Label控件。
//通过循环得到网页上的label
if (ds.Tables[0].Rows.Count > 0)
{
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
//通过循环得到网页上的label
foreach (Control c in Page.Controls)
{
foreach (Control childc in c.Controls)
{
if (childc is Label)
{
if (((Label)childc).ID.Length > 4)
{
//判断,截取Label控件信息进行判断
if (((Label)childc).ID.Substring(3, 3) == ds.Tables[0].Rows[i]["r_gwdm"].ToString())
{
((Label)childc).Text = ds.Tables[0].Rows[i]["sl"].ToString();//赋值
}
}
}
}
}
}
}
转载于:https://www.cnblogs.com/liulanglang/archive/2008/10/20/1314787.html
本文介绍了一种从数据集中获取信息,并将其动态赋值给网页上Label控件的方法。通过循环遍历数据集与网页控件,实现对特定Label控件的精准赋值。
540

被折叠的 条评论
为什么被折叠?



