Note that there are some explanatory texts on larger screens.

plurals
  1. POget value from dynamic Textbox
    text
    copied!<p>I hava some arrays to save my controls. when call a function initialize arrays and save in arrays my controls. </p> <p>Code:</p> <pre><code>private Label[] lblName; private TextBox[] txtName; private Label[] lblSurname; private TextBox[] txtSurname; private Label[] lblInstitution; private TextBox[] txtInstitution; private Label[] lblCountry; private TextBox[] txtCountry; private Label[] lblEmail; private TextBox[] txtEmail; private PlaceHolder PlaceHolder1; public int NumberOfOtherAuthors() { Int32 index = Convert.ToInt32(NumberList.SelectedValue); return index; } public void GUIofOtherAuthor() { int authors; int i = 0; int j = 1; authors = NumberOfOtherAuthors(); lblName = new Label[authors]; txtName = new TextBox[authors]; lblSurname = new Label[authors]; txtSurname = new TextBox[authors]; lblInstitution = new Label[authors]; txtInstitution = new TextBox[authors]; lblCountry = new Label[authors]; txtCountry = new TextBox[authors]; lblEmail = new Label[authors]; txtEmail = new TextBox[authors]; PlaceHolder1 = new PlaceHolder(); for (i = 0; i &lt; authors; i++) { Label authorInformation = new Label(); authorInformation.Text = "Information for Author " + j.ToString() + " :"; lblName[i] = new Label(); lblName[i].Text = "Name:"; txtName[i] = new TextBox(); lblSurname[i] = new Label(); lblSurname[i].Text = "Surname:"; txtSurname[i] = new TextBox(); lblInstitution[i] = new Label(); lblInstitution[i].Text = "Institution:"; txtInstitution[i] = new TextBox(); lblCountry[i] = new Label(); lblCountry[i].Text = "Country:"; txtCountry[i] = new TextBox(); lblEmail[i] = new Label(); lblEmail[i].Text = "Email:"; txtEmail[i] = new TextBox(); PlaceHolder1.Controls.Add(new LiteralControl("&lt;table&gt;")); PlaceHolder1.Controls.Add(new LiteralControl("&lt;span style=\"font-weight:bold;\" ")); PlaceHolder1.Controls.Add(authorInformation); PlaceHolder1.Controls.Add(new LiteralControl("&lt;/span&gt;")); PlaceHolder1.Controls.Add(new LiteralControl("&lt;tr&gt;&lt;td&gt;")); PlaceHolder1.Controls.Add(lblName[i]); PlaceHolder1.Controls.Add(new LiteralControl("&lt;/td&gt;&lt;td&gt;")); PlaceHolder1.Controls.Add(txtName[i]); PlaceHolder1.Controls.Add(new LiteralControl("&lt;/td&gt;&lt;/tr&gt;")); PlaceHolder1.Controls.Add(new LiteralControl("&lt;tr&gt;&lt;td&gt;")); PlaceHolder1.Controls.Add(lblSurname[i]); PlaceHolder1.Controls.Add(new LiteralControl("&lt;/td&gt;&lt;td&gt;")); PlaceHolder1.Controls.Add(txtSurname[i]); PlaceHolder1.Controls.Add(new LiteralControl("&lt;/td&gt;&lt;/tr&gt;")); PlaceHolder1.Controls.Add(new LiteralControl("&lt;tr&gt;&lt;td&gt;")); PlaceHolder1.Controls.Add(lblInstitution[i]); PlaceHolder1.Controls.Add(new LiteralControl("&lt;/td&gt;&lt;td&gt;")); PlaceHolder1.Controls.Add(txtInstitution[i]); PlaceHolder1.Controls.Add(new LiteralControl("&lt;/td&gt;&lt;/tr&gt;")); PlaceHolder1.Controls.Add(new LiteralControl("&lt;tr&gt;&lt;td&gt;")); PlaceHolder1.Controls.Add(lblCountry[i]); PlaceHolder1.Controls.Add(new LiteralControl("&lt;/td&gt;&lt;td&gt;")); PlaceHolder1.Controls.Add(txtCountry[i]); PlaceHolder1.Controls.Add(new LiteralControl("&lt;/td&gt;&lt;/tr&gt;")); PlaceHolder1.Controls.Add(new LiteralControl("&lt;tr&gt;&lt;td&gt;")); PlaceHolder1.Controls.Add(lblEmail[i]); PlaceHolder1.Controls.Add(new LiteralControl("&lt;/td&gt;&lt;td&gt;")); PlaceHolder1.Controls.Add(txtEmail[i]); PlaceHolder1.Controls.Add(new LiteralControl("&lt;/td&gt;&lt;/tr&gt;")); PlaceHolder1.Controls.Add(new LiteralControl("&lt;/table&gt;&lt;br /&gt; ")); Panel1.Controls.Add(PlaceHolder1); j++; } } </code></pre> <p>Now i want to take the value of textboxes in another function <code>public void UploadForm(){...}</code>. I try it</p> <pre><code>int i; int numberOfOtherAuthors = NumberOfOtherAuthors(); for(i=0; i&lt;numberOfOtherAuthors; i++) { String a = txtname[i].text } </code></pre> <p>The Textboxes values I want to upload to the database, but let's say we save them to a string. When i do this, i have the NullReferenceException. So how to get the value of this textboxes??? Thanks</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload