I am quite new in asp.net. I am wonder how can I get the value of the textbox that create dynamically from C#.
this code is the way i create the textbox from page load event...
for( int i =0; i<30; i++){
TextBox txt = new TextBox();
txt.Text = "ASDASDASD";
txt.ID = "txt - " + i.ToString();
data.Controls.Add(txt);
}
I wonder how can I get the value of the text box in button_click event. I tried string test = "txt - " + i.ToString(); but I unable to get it.
thanks for the help.
Create an array or list of textboxes:
And assign a new textbox to each position:
To get the value of any textbox, do: