日期:2014-05-17  浏览次数:20684 次

repeater中CheckBox根据数据库中记录默认选中

                for (int i = 0; i < Repeater1.Items.Count; i++)
                {
                    DataTable dtm = GWDP.GetMenuShowMessage();
                    for (int j = 0; j < dtm.Rows.Count; j++)
                    {
                        Label CKID = (Label)Repeater1.Items[i].FindControl("CheckBoxID");
                        if (dtm.Rows[j]["MENU_ID"].ToString() == CKID.Text.ToString())
                        {
                            CheckBox chk = (CheckBox)Repeater1.Items[i].FindControl("cboSelectSingle");
                            chk.Checked = true;
                        }
                    }
                }

这是我的代码 我是在首次加载的时候判断 怎么一点效果都没有呢 

------解决方案--------------------
Label CKID = (Label)Repeater1.Items[i].FindControl("CheckBoxID");
是不是找错了,是label?