读书人

在Repeater中放一个checkbox怎么给这

发布时间: 2012-01-05 22:36:54 作者: rapoo

在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,得到一行不实际

读书人网 >asp.net

热点推荐