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

关于CheckBoxList的取值问题
我的CheckBoxList是在repeater的ItemDataBound事件里面动态生成的,现在在按钮的添加事件下面应该如何获取CheckBoxList选中的值呢?求助!

------解决方案--------------------
贴点源码上来看看吧,应该用FindControl方法可以找到的
------解决方案--------------------
遍历repeater
FindControl().
Checkboxlist chkblist=(Checkboxlist)Repeater.Item.FindControl("");

 foreach (ListItem items in CheckBoxList1.Items
{
    items.Selected = true;
    //...
}

------解决方案--------------------
以前写的一个 。你看下有用么


 for (int i = 0; i < Repeater1.Items.Count; i++)
                {
                    Repeater repeater2 = Repeater1.Items[i].FindControl("Repeater2") as Repeater;
                    if (repeater2 != null)
                    {
                        for (int j = 0; j < repeater2.Items.Count; j++)
                        {
                            CheckBox cb = repeater2.Items[j].FindControl("chkbox2") as CheckBox;
                            cb.Checked = false;
                            Label lbnum = repeater2.Items[j].FindControl("Label1") as Label;
                            for (int h = 0; h < ssid.Length - 1; h++)
                            {
                                if (lbnum.Text == ssid[h].ToString())
                                {
                                    cb.Checked = true;
                              &nb