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

Repeater中ItemTemplate中的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;
                        }
                    }
                }

这是我的代码 没有效果 

------解决方案--------------------
在ItemDataBound事件中处理,就是每绑定一行数据就触发一次的那个事件中