日期:2014-05-18  浏览次数:20383 次

在Repeater中放一个checkbox,如何给这个控件写事件来操作选择的行


------解决方案--------------------
双击控件后在cs里的使劲就可以了。
------解决方案--------------------
楼主是要怎么操作选择的行?

------解决方案--------------------
不知道搂住需要的是在后台产生事件还是在前台产生事件?
------解决方案--------------------
6楼的代码是写在,Repeater绑定之后。

也可以这样写,在Repeater_itemCommand事件中;
CheckBox cb = (CheckBox)e.Item.FindControl( "CheckBox1 ");
if (cb.Checked)
{
Label lb = (Label)e.Item.FindControl( "Label1 ");
int rid = Convert.ToInt32(lb.Text);
}



------解决方案--------------------
js
------解决方案--------------------

if(e.Item.ItemType==ListItemType.Item||e.Item.ItemType==ListItemType.AlternatingItem){
CheckBox cb = (CheckBox)e.Item.FindControl( "CheckBox1 ");
if (cb.Checked)
{
Label lb = (Label)e.Item.FindControl( "Label1 ");
int rid = Convert.ToInt32(lb.Text);
}

}
------解决方案--------------------
Repeater_itemCommand事件中;
CheckBox cb = (CheckBox)e.Item.FindControl( "CheckBox1 ");
if (cb.Checked)
{
Label lb = (Label)e.Item.FindControl( "Label1 ");
int rid = Convert.ToInt32(lb.Text);
}
这个方法只是把你选择行的ID赋给了rid,你要实现什么效果需要在CheckBox的事件里面写
------解决方案--------------------
要自己写代码的,可能得到当前行的某个ID,得到一行不实际