我的CheckBoxList是在repeater的ItemDataBound事件里面动态生成的,现在在按钮的添加事件下面应该如何获取CheckBoxList选中的值呢?求助!
解决方案 »
- jquery遍历RadioButtonList
- vs 错误还是程序错误! 请大家看看!
- 给70分
- 页面回发后AJAX 丢失
- 一个简单的问题,由于第一次接触,还请原谅,谢谢!!
- 类型“TextBox”的控件“_ctl0_queryText”必须放在具有 runat=server 的窗体标记内
- 显示HTML标记本身的问题
- 请教大家用VB和C#编写ASP.NET有什么区别?
- 配置WEB.CONFIG出现问题,郁闷啊,在线等待!!!!
- JSONP 跨域问题
- ASP.NET 3.5 MVC "NorthWind.Model.Categories"不包含”GetEnumerator"的公共定义
- 把textbox控件的Enabled属性改为false后,然后通过javascript给该控件赋值,页面上能显示出来赋于的值,但当我需要保存时在.cs文件中取它
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;
}
} }
}
}
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{ Label lbltype = e.Item.FindControl("lblType") as Label;
Label lblID = e.Item.FindControl("lblID") as Label;
Panel pan = e.Item.FindControl("pan") as Panel;
type =Convert.ToInt32(lbltype.Text);
DataSet ds = queBll.GetList(0, " id=" + lblID.Text + " ", "");
string[] d = ds.Tables[0].Rows[0]["question"].ToString().Replace("\r\n", "\r").Split(new char[] { '\r' });
if (type == 28)//找到repeater里面的RadioButtonList 单选
{
RadioButtonList rndanxuan = new RadioButtonList();
rndanxuan.ID = "rndanxuan";
rndanxuan.DataSource = d;
rndanxuan.DataBind();
pan.Controls.Add(rndanxuan);
}
if (type == 29)
{
RadioButtonList rbdanxuanwenben = new RadioButtonList();
rbdanxuanwenben.ID = "rbdanxuanwenben";
rbdanxuanwenben.DataSource = d;
rbdanxuanwenben.DataBind();
pan.Controls.Add(rbdanxuanwenben);
}
if (type == 30)
{
CheckBoxList chkduo = new CheckBoxList();
chkduo.ID = "chkduo";
chkduo.DataSource = d;
chkduo.DataBind();
pan.Controls.Add(chkduo);
}
}
}//然后我要在按钮的添加事件下面获取这些选中的值
protected void bnt_add_Click(object sender, EventArgs e)
{
for (int i = 0; i < RepList.Items.Count; i++)
{
RadioButton rbl = RepList.Items[i].FindControl("rbdanxuanwenben") as RadioButton;
if (rbl != null)
{
//记录选中的答案 if (rbl.Checked)
{
}
}
}
}
我应该怎么取值呢