获取中继器的物品
我试图在页面移动(分页)之前获取中继器项目的所有中继器选定复选框,并将它们存储在某个位置。
foreach (RepeaterItem ri in rpt.Items)
{
CheckBox box = (CheckBox)ri.FindControl("chkBox");
if (box.Checked)
{
...
}
}
问题是我从哪里调用这个函数? 我尝试从 ObjectDataSource1_Selected (我使用 objectdatasource 填充中继器)和 ObjectDataSource1_Selecting 调用它,但 rpt.Items.Count 也是 0。
rpt_PreRender() 事件,返回正确的项目数,但它发生在选择复选框之前,而不是后。
我能做些什么?
I am trying to get all repeater's selected checkboxes of repeater's item just before page movement (pagination), and store them in some place.
foreach (RepeaterItem ri in rpt.Items)
{
CheckBox box = (CheckBox)ri.FindControl("chkBox");
if (box.Checked)
{
...
}
}
The problem is where do i call this function from?
I've tried to call it from ObjectDataSource1_Selected (I use objectdatasource to populate repeater) and ObjectDataSource1_Selecting but rpt.Items.Count is also 0.
rpt_PreRender() event, returns the right number of items but it happens before the selection of checkboxes and not after.
What can i do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您正在寻找的方式是不可能的...请尝试使用此代码...
the way you are looking is not possible...plz try using this code...
Repeater 没有内置分页(如 GridView 或其他复杂控件),因此它不提供诸如 PageIndexChanging 等事件。 因此,我假设您有自己的页面导航实现。 因此,您应该调用您在该实现的函数中提供的函数。
如果问题与分页无关,我会简单地建议
ItemDataBound/ItemCreated
事件。The Repeater does not have built-in Pagination (like the
GridView
or other complex controls) so it does not offer events such as thePageIndexChanging
. I assume therefore, that you have your own Page navigation implementation. You should therefore call the function you have presented within that implemented function.If the question was unrelated to Paging, I'd have simply suggested the
ItemDataBound/ItemCreated
events.