Wednesday, July 15, 2009

dynamically created controls finding method

function call
===========
IterateControls(this);

method implementaion
==================
private void IterateControls(Control parent)
{
foreach (Control child in parent.Controls)
{
if (child.GetType().ToString().Equals("System.Web.UI.WebControls.TextBox") && child.ID.IndexOf("uxValueTxt") == 0)
{
TextBox textbox = (TextBox)child;
_textString += textbox.Text + ",";
}
else
if (child.GetType().ToString().Equals("System.Web.UI.WebControls.DropDownList") && child.ID.IndexOf("uxValueDdl") == 0)
{
DropDownList dropdown = (DropDownList)child;
if (dropdown.Items.Count != 0)
{
_textString += dropdown.SelectedItem.Text + ",";
}
}
if (child.Controls.Count > 0)
{
IterateControls(child);
}
}
uxHidTextString.Value = _textString;
}

No comments:

Post a Comment