首页 新闻 会员 周边

利用Repeater嵌套实现点击第二个第一个隐藏

0
悬赏园豆:20 [已解决问题] 解决于 2015-09-15 09:41
所属书库 状态
三级书库 设置过关积分
皮皮鲁传---积分:50  (选读)
三国演义---积分:50  (必读)
四级书库 设置过关积分
小王子---积分:50  (必读)
格列佛游记---积分:50  (必读)
五级书库 设置过关积分
六级书库 设置过关积分
七级书库

static Repeater trpt = null;
static Button tbtn = null;
protected void rptResultsList_ItemCommand(object source, RepeaterCommandEventArgs e)
{
  if (e.CommandName == "show")
  {
    if (tbtn != null && trpt != null)
    {
      if (tbtn.Text == "▼")
      {
        tbtn.Text = "▲";
        trpt.DataSource = string.Empty;
        trpt.DataBind();
      }
    }
    UserIdentity identity=User.Identity as UserIdentity;
    if(identity != null)
    {
      DataSet ds = Exam.BLL.tb_School_QuestionClsBLL.GetInstance().Get_School_QuestionClsRelationIdBySchoolId(identity._schoolID,int.Parse(e.CommandArgument.ToString()));
      if (ds != null)
      {
        Button btn = e.Item.FindControl("btn") as Button;
        Repeater rpt = e.Item.FindControl("rptResults2") as Repeater;
        tbtn = btn;
        trpt = rpt;
        if (btn.Text == "▲")
        {
          btn.Text = "▼";
          rpt.DataSource = ds;
          rpt.DataBind();
        }
        else
        {
          btn.Text = "▲";
          rpt.DataSource = string.Empty;
          rpt.DataBind();
        }
      }
    }
  }
}

这样做为何没能实现

夜城的主页 夜城 | 初学一级 | 园豆:184
提问于:2015-09-11 10:18
< >
分享
最佳答案
0

直接用Visable属性吧。

收获园豆:20
forhells | 小虾三级 |园豆:724 | 2015-09-12 08:54

关键不在这,多个repeater当中找到上一次点击的控件才是关键,但我已经找到了可是不管用啊if (tbtn != null && trpt != null)
    {
      if (tbtn.Text == "▼")
      {
        tbtn.Text = "▲";
        trpt.DataSource = string.Empty;
        trpt.DataBind();
      }
    }

夜城 | 园豆:184 (初学一级) | 2015-09-14 09:30
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册