查找repeater headertemplate 中的Literal dropdownlist

//下拉dorpdownlist时
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            DropDownList ddl = null;
            foreach (RepeaterItem item in Repeater1.Controls)
            {
                if (item.ItemType == ListItemType.Header)
                {

                    ddl = ((DropDownList)item.FindControl("Ddlshowtype"));
                    break;
                }
            }
            int showtypeid = Convert.ToInt32(ddl.SelectedValue);
            ViewState["showtypeid"] = showtypeid;
            Bindrepeater(Convert.ToInt32(ViewState["showid"]), showtypeid);
        }
        //必须在这里绑定,不然非常麻烦
        protected void Repeater1_ItemCreated(object sender, RepeaterItemEventArgs e)
        {
            int showid = Convert.ToInt32(ViewState["showid"]);
            int showtypeid = Convert.ToInt32(ViewState["showtypeid"]);
            if (e.Item.ItemType == ListItemType.Header)
            {
                Showprod sp = new Showprod();
                if (showtypeid > 0)
                {
                    ((Literal)e.Item.FindControl("Ltnow")).Text = sp.SelsByShowtypeid(showtypeid).Count.ToString();
                    ((Literal)e.Item.FindControl("Ltall")).Text = sp.SelsByShowid(showid).Count.ToString();
                }
                else
                {
                    ((Literal)e.Item.FindControl("Ltnow")).Text = sp.SelsByShowid(showid).Count.ToString();
                    ((Literal)e.Item.FindControl("Ltall")).Text = sp.SelsByShowid(showid).Count.ToString();
                }

                Showtype st = new Showtype();
                IList<ShowtypeInfo> isti = st.Sels(showid);
                DropDownList ddl = (DropDownList)e.Item.FindControl("Ddlshowtype");
                for (int i = 0; i < isti.Count; i++)
                {
                    ddl.Items.Insert(i, new ListItem(isti[i].Showtypename.ToString(), isti[i].Showtypeid.ToString()));
                    if (isti[i].Showtypeid == Convert.ToInt32(ViewState["showtypeid"]))
                    {
                        ddl.Items[i].Selected = true;
                    }
                }
                ddl.Items.Insert(0, new ListItem("显示全部全部主题", "0"));               
            }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值