保持内部中继器的旧值

时间:2014-07-15 17:05:30

标签: asp.net stored-procedures repeater ascx

我有两个嵌套的转发器,其代码位于两个单独的aspx页面上,而父转发器在每一行上都有一个按钮。在按钮单击时,内部转发器被调用并加载。

此外,通过执行存储过程来加载两个转发器的数据。

现在,例如,如果我单击父转发器第二行上的按钮,则会显示内部内部子转发器。但是,如果我单击父转发器的第一行,则会显示该行的内部子转发器,但第二行的已加载值将消失。

如何在每次点击新按钮的情况下保留内部子转发器的已加载值?

//父转发器代码

 protected void rptCoverage_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "CoverageDetails")
        {
            //changing the button to '-'
            var btn = e.Item.FindControl("btnShowCoveragedetails") as Button;
            var policy = e.Item.FindControl("lblPolicyNo") as Label;
            var description = e.Item.FindControl("lblDescription") as Label;
            var idPerson = id_person;

            if (btn.Text == "+")
            {
                btn.Text = "-";
            }
            else
            {
                btn.Text = "+";
            }

            Session["idPerson"] = idPerson;
            Session["policy"] = policy.Text.Trim();
            Session["description"] = description.Text.Trim();


            var placeHolder = e.Item.FindControl("UCPlaceHolder") as Control;

            placeHolder.Controls.Add((PolicyDetailsTemplate1)Page.LoadControl("~/Shared/Controls/PolicyDetailsTemplate1.ascx")); 

            //check to see if the template was loaded earlier
            //var tempalte = placeHolder.FindControl("")


        }
    }

// Child Inner repeater Code

        protected void Page_Load(object sender, EventArgs e)
    {
        CustomerPortalWebContentEntities context = new CustomerPortalWebContentEntities();
        RetrievePolicyDetails policyDetails = new RetrievePolicyDetails();
        List<PolicyDetails> polDetails = policyDetails.GetPolicyDetails((string)Session["idPerson"], (string)Session["policy"], (string)Session["description"]);

        rptPolicyDetails.DataSource = polDetails;
        rptPolicyDetails.DataBind();

        Session.Clear();

    }

// OUTPUT片段 Inner Repeater on first button click Inner Repeater on Second button click

基本上,如何在每次点击新按钮时加载内部子转发器上的数据?

0 个答案:

没有答案