问候,我会尽量让这个简短而清晰
我有一个 NumericTextBox 和一个按钮,按下按钮后,它会根据 NumericTextBox 上引入的值告诉中继器A应该重复多少次:
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 中继器”的功能?有什么想法我可以解决这个问题吗?