おそらく理解されていないので、質問を変更します。私の英語も申し訳ありません...
それらを配列に入れる TextBoxes を動的に作成します。
私のコードの一部:
public partial class NewArticleForm : System.Web.UI.Page
{
private Label[] lblName;
private TextBox[] txtName;
private Label[] lblSurname;
private TextBox[] txtSurname;
private PlaceHolder PlaceHolder1;
public int NumberOfOtherAuthors()
{
Int32 index = Convert.ToInt32(NumberList.SelectedValue);
return index;
}
public void dataofOtherAuthor()
{
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];
PlaceHolder1 = new PlaceHolder();
for (i = 0; i < 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();
PlaceHolder1.Controls.Add(authorInformation);
PlaceHolder1.Controls.Add(lblName[i]);
PlaceHolder1.Controls.Add(txtName[i]);
PlaceHolder1.Controls.Add(lblSurname[i]);
PlaceHolder1.Controls.Add(txtSurname[i]);
// Add a spacer in the form of an HTML <BR> element.
Panel1.Controls.Add(PlaceHolder1);
j++; } }
protected void NumberList_SelectedIndexChanged(object sender, EventArgs e)
{
dataofOtherAuthor();
}
private void UploadForm()
{
int numberOfOtherAuthors = NumberOfOtherAuthors();
int i=0;
for (i = 0; i < numberOfOtherAuthors; i++)
{
Label1.Text = txtName[i].Text;
}
}
protected void btnUpload_Click(object sender, EventArgs e)
{
UploadForm();
}
}
テキストボックスの値を取得するにはどうすればよいですか?? 具体的には、データベースにデータを渡したいです。ラベルは、値を取得するかどうかのテストです。
ありがとうございました!!!