Can someone please tell me what is wrong with the following code or if it is even legal? I am trying to access the text in a multitude of textboxes without having to go to each textbox manually. so i named them all similar enough. their names are all variations of
txtSG1D1
with only the numbers varying. the problem here is that s2 cannot be equal to the text of curText. I get an error message that seems to imply that curText is not a real object. I must create an instance by using keyword new.
Or is there some other way of creating an array of controls. I really do not want to resign myself to the fate of having to code 30 textboxes by hand.
Thanks.
TextBox curText = newTextBox();
curText = (TextBox) this.Controls["txtSG" + x.ToString() + "D" + y.ToString()];
s2 = curText.Text;