[英]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.