日期:2014-05-17  浏览次数:20504 次

很急很急很急 两个repeater嵌套 外层的按钮的单击事件不起作用,在线等……!
啥也不说了先贴代码
cs文件代码
C# code

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace Publisher.web.Management.BookSystem
{
    public partial class booktype : System.Web.UI.Page
    {
        public readonly Bll.Book.BookType bllBookType = new Publisher.Bll.Book.BookType();
        protected void Page_Load(object sender, EventArgs e)
        {

            if (Request.QueryString["fixid"] != null)
            {
                string fixid = Request.QueryString["fixid"];
                Model.Book.booktype modbooktype = bllBookType.GetModel(int.Parse(Common.DESEncrypt.Decrypt(fixid)));
                txtTypename.Text = modbooktype.TypeName;
                dplParentType.Items.FindByValue(modbooktype.TypeID.ToString()).Selected = true;
            }
            // rptBookTypeRoot.ItemCommand+=new RepeaterCommandEventHandler(rptBookTypeRoot_ItemCommand);
            //绑定repeater控件
            if (!IsPostBack)
            {
                BindRepeater();
            }

        }

        protected void BindRepeater()
        {
            DataSet dsRootlist = bllBookType.GetList("ParentID = 0");
            rptBookTypeRoot.DataSource = dsRootlist;
            rptBookTypeRoot.DataBind();
            //绑定根类型类表(新增)
            ListItem listItRoot = new ListItem("根类型", "0");
            dplParentType.DataSource = dsRootlist;
            dplParentType.DataTextField = "typename";
            dplParentType.DataValueField = "typeid";
            dplParentType.DataBind();
            dplParentType.Items.Insert(0, listItRoot);
            //绑定根类型类表(新增)
            dplFixParentType.DataSource = dsRootlist;
            dplFixParentType.DataTextField = "typename";
            dplFixParentType.DataValueField = "typeid";
            dplFixParentType.DataBind();

            dplFixParentType.Items.Insert(0, listItRoot);


        }

        /// <summary>
        /// 绑定内层数据列表
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void rptBookTypeRoot_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {

            //判断里层repeater处于外层repeater的哪个位置( AlternatingItemTemplate,FooterTemplate,

            //HeaderTemplate,,ItemTemplate,SeparatorTemplate)
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Repeater rptTemp = e.Item.FindControl("rptItemList") as Repeater;//找到里层的repeater对象
                DataRowView rowv = (DataRowView)e.Item.DataItem;//找到分类Repeater关联的数据项 
                rptTemp.DataSource = bllBookType.GetList("ParentID=" + rowv["TypeID"]);
                rptTemp.DataBind();


            }
        }

        //


        //protected void rptBookTypeRoot_ItemCommand(object sender, RepeaterCommandEventArgs e)
        //{
        //    Response.Write("fuck");
        //}
        //


        /// <summary>
        /// 删除类型用方法
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
//这里设置的断点就是不执行!!!!郁闷的要屎掉了
        protected void lbtnDelItem_Click(object sender, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "del")
            {
                Response.Write("fuck");
            }

            //if (e.CommandSource.ToString() == "System.Web.UI.WebControls.LinkButton")
            //{
            //    LinkButton lbtn = (LinkButton)e.CommandSource;

            //    bllBook