hello
I created a form with 3 textbox and I want to add another dynamic text box when the user click the button;
Everything working fine, but when I try to read the data using FindControl it doesnt find anything.
If I create the dynamic buttons on Page_Init, its find them, but if I create then on the button click event it wont find them using FindControl.
what can I do ?
VulpesPosted Nov 18, 2014, 12:44 PM
It appears that the ViewState variable is not refreshed until AFTER the page has loaded.
I'm cheating a bit but this is working OK for me without the need to click the MoreBtn twice:
gavriel ankriPosted Nov 19, 2014, 7:21 AM
you did it!
Great. you are the best
gavriel ankriPosted Nov 17, 2014, 11:45 AM
}
VulpesPosted Nov 16, 2014, 6:30 PM
gavriel ankriPosted Nov 16, 2014, 2:07 AM
but if I create them on page_load, its only fire on the second click, but not in the first click.
do you know how can it work on the first click ?
VulpesPosted Nov 15, 2014, 12:36 PM
You can't therefore create them on a button click.
You either need to create them in Page_Init or each time the page loads in Page_Load.
gavriel ankriPosted Nov 15, 2014, 11:29 AM
{
for (int i = guestList.Count; i < guestList.Count; i++)
{
TextBox newtxt = new TextBox();
newtxt.ID = "lbName" + i;
panel2.controls.add (newtxt);
}
this work fine, but when i try to read the data:
el0.SetAttribute("fullName", ((TextBox)FindControl("lbName" + i)).Text;
I get an error that it cant find the specific textbox
Abhay ShankerPosted Nov 15, 2014, 10:50 AM