首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >访问嵌套中继器

访问嵌套中继器
EN

Stack Overflow用户
提问于 2013-07-10 20:06:17
回答 1查看 378关注 0票数 0

问候,我会尽量把这句话说清楚

我有一个NumericTextBox和一个按钮,按下按钮它告诉中继器A,它应该根据NumericTextBox上引入的值重复多少次:

代码语言:javascript
复制
    protected void ButtonRepeaterA_Click(object sender, EventArgs e)
    {
        string x = RadNumericTextBoxRepeatsOnA.Text.Trim();
        int y = Convert.ToInt32(x);

        int[] RowCount = new int[y];
        RepeaterA.DataSource = RowCount;
        RepeaterA.DataBind();

        int currentYear = DateTime.Now.Year;

        for (int i = currentYear; i <= currentYear + 100; i++)
        {
            //DropDownCCYear.Items.Add(new RadComboBoxItem(i.ToString(), i.ToString()));

            foreach (RepeaterItem item in RepeaterA.Items)
            {
                RadComboBox DropDownCCYear = (RadComboBox)item.FindControl("DropDownCCYear");
                DropDownCCYear.Items.Add(new RadComboBoxItem(i.ToString(), i.ToString()));
            }
        }


    }

中继器B是中继器A中的一个问题。

它的行为类似于中继器A,但我只希望按下按钮会影响按钮所在的中继器,因此它不会清除中继器B的其他重复中引入的控件上引入的数据,如果我使用如下“前端中继器”,会发生什么情况:

代码语言:javascript
复制
    protected void ButtonRepeaterB(object sender, EventArgs e)
    {

        foreach (RepeaterItem item in RepeaterA.Items)
        {
            Repeater RepeaterB = (Repeater)item.FindControl("RepeaterB");
            RadNumericTextBox RadNumericTextBoxRepeatsOnB = (RadNumericTextBox)item.FindControl("RadNumericTextBoxRepeatsOnB");

            string x = RadNumericTextBoxRepeatsOnB.Text.Trim();
            int y = Convert.ToInt32(x);

            int[] RowCount = new int[y];
            RepeaterB.DataSource = RowCount;
            RepeaterB.DataBind();
        }
    }

是否有“用于此中继器”的-like功能?有什么办法吗?

EN

回答 1

Stack Overflow用户

发布于 2013-07-10 21:12:04

Repeater有一个ItemCommand事件,我认为它对您很有用。当ButtonClick事件发生时,如果您没有设置ButtonClick事件处理程序,ItemCommand事件将吞噬它。

ItemCommand事件上,您可以使用e参数来确定哪个按钮,使用sender来确定它来自哪个Repeater

我被你的问题搞糊涂了,但我想这是你开车去找的答案。这有用吗?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17579946

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档