protected void Page_Load(object sender, EventArgs e) { //if (!Page.IsValid) return; int n = 100; // now, create n TextBoxes, adding them to the PlaceHolder TextBoxesHere for (int i = 0; i < n; i++) { RBLPlaceHolder.Controls.Add(new RadioButtonList()); } // now, set the Text property of each TextBox IterateThroughChildren(this); } void IterateThroughChildren(Control parent) { foreach (Control c in parent.Controls) { if (c.GetType().ToString().Equals("System.Web.UI.WebControls.RadioButtonList") && c.ID == null) { ((RadioButtonList)c).Items.Add("A"); ((RadioButtonList)c).Items.Add("B"); ((RadioButtonList)c).Items.Add("C"); ((RadioButtonList)c).Items.Add("D"); ((RadioButtonList)c).RepeatDirection = RepeatDirection.Horizontal; count++; } if (c.Controls.Count > 0) { IterateThroughChildren(c); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)