I have a textbox generated by parsing an xml file.
TextBox tb = new TextBox;
tb.ID = "MYDATA"
Parent.Controls.Add(tb);
I then read another Xml file for the data to populate the created TextBox. I have been trying all sorts of databinging and setting the text property to a dataset, but cannot figure it out. If I set the text property at creation to say:
MyDataSet.Tables[0].rows[0].["MYDATA"].ToString();
I get an error because the dataset hasn’t been created and wont be until the form has been created. Am I going about this wrong? Can’t I someway specify that the data to fill the textbox is coming from the dataset without already creating it?
If you’re populating the
DataSetin the same method that creates theTextBox, you should be able to do this:If you’re populating the
DataSetin another method after theTextBoxhas been created, you can use theFindControlmethod to search the parent container of theTextBox: