首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

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

2013-11-23 
repeater中CheckBox根据数据库中记录默认选中for (int i 0 i Repeater1.Items.Count i++){DataTable

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?

热点排行