[英]Accessing Nested repeaters
问候,我会尽量简短明了
我有一个NumericTextBox和一个Button,按下按钮时,它会告诉中继器A根据NumericTextBox上引入的值将其重复多少次:
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其他重复中控件上引入的数据。我使用“ foreach转发器”,如下所示:
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();
}
}
是否有类似“ forthis转发器”的功能? 任何想法,我怎么能做到这一点?
Repeater
具有一个ItemCommand
事件,我认为这对您很有用。 当Button
的Click
事件发生时,如果尚未设置Button
的Click
事件处理程序,则ItemCommand
事件将吞噬它。
在ItemCommand
事件上,可以使用e
参数确定哪个按钮,并使用sender
确定它来自哪个Repeater
。
您的问题让我有些困惑,但是我认为这是您要解决的问题。 有帮助吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.