You have to bind this countrols at postback again before accessing them.

On Wed, Dec 2, 2009 at 5:17 PM, Raghupathi Kamuni <[email protected]>wrote:

> child.ID.IndexOf("lstDynamicListBox") != -1
>
>
> On Wed, Dec 2, 2009 at 1:05 PM, Pratiksha Saxena <
> [email protected]> wrote:
>
>> Hi,
>>
>> I have a page in which i have table and some other controls.
>> On click of button i want to add Listbox and textbox .
>> When user input values in Listbox and TextBox i cannot get value of these
>> controls in IterateControls Method.
>>
>> Main problem is i am not able to find my dynamic control/.
>>
>>
>> Here is my code
>>
>> On Button1_click
>> {
>>         ListBox  _ListBox = new ListBox();
>>          _ListBox.ID = "lstDynamicListBox";
>>     TextBox  _TextBox = new TextBox();
>>          _TextBox.ID = "lstDynamicTextBox";
>>
>>
>>      Panel1.Controls.Add(_ListBox);
>>     Panel1.Controls.Add(_TextBox);
>> }
>>
>>
>>
>>
>>
>> On Button2_Click  //I want to retrieve value
>> {
>>   void IterateControls(Control parent)
>>     {
>>         foreach (Control child in parent.Controls)
>>         {
>>             if
>> (child.GetType().ToString().Equals("System.Web.UI.WebControls.Listbox")
>>                && child.ID.IndexOf("lstDynamicListBox") == 0)
>>             {
>>                 ListBox listbox = (ListBox)child;
>>
>>             }
>>
>>             if (child.Controls.Count > 0)
>>             {
>>                 IterateControls(child);
>>             }
>>         }
>>     }
>>
>>
>>
>>
>>
>>
>>
>>
>

Reply via email to