获取中继器的物品 [英] Get Repeater's Items

查看:67
本文介绍了获取中继器的物品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图在页面移动(分页)之前获取转发器项目的所有选中的转发器复选框,并将其存储在某个位置.

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)
       {
          ...
       }
  }

问题是我从哪里调用此函数?我试图从ObjectDataSource1_Selected(我使用objectdatasource来填充转发器)和ObjectDataSource1_Selecting中调用它,但是rpt.Items.Count也为0.

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()事件,返回正确数量的项目,但它发生在选择复选框之前,而不是之后.

rpt_PreRender() event, returns the right number of items but it happens before the selection of checkboxes and not after.

我该怎么办?

推荐答案

不可能按照您所期望的方式...请尝试使用此代码...

the way you are looking is not possible...plz try using this code...

if (Repeater1.Items.Count > 0)
    {
        for (int count = 0; count < Repeater1.Items.Count; count++)
        {
            CheckBox chk = (CheckBox)Repeater1.Items[count].FindControl("CheckBox1");
            if (chk.Checked)
            {

            }
        }
    }

这篇关于获取中继器的物品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆