let it be
行到水穷处 坐看云起时
本人从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();//赋值
                                }
                            }
                        }
                    }
                }
            }
        }
posted on 2008-10-20 09:03  流浪浪  阅读(2900)  评论(2编辑  收藏  举报