怎么获得每行的值 动态添加的啊 急急急!!!!
xx小台灯 2013-01-25 11:48:08
int tableRows = rows; //接收用户设置行数
int tableCells = 4; //4列
int tbId = 1; //由于一行有多个Textbox,要设置每个TextBox的ID唯一性。
for (int i = 1; i <= tableRows; i++)
{
TableRow tableRow = new TableRow();
for (int j = 1; j <= tableCells; j++)
{
switch (j)
{
case 1: //第一列
TableCell tableCell1 = new TableCell();
tableCell1.BorderWidth = Unit.Pixel(1);
FileUpload fileUpload = new FileUpload();
fileUpload.ClientIDMode = ClientIDMode.Static;
fileUpload.ID = "FileUpload" + i.ToString();
tableCell1.Controls.Add(fileUpload);
tableRow.Cells.Add(tableCell1);
break;
case 2: //第二列
TableCell tableCell2 = new TableCell();
tableCell2.BorderWidth = Unit.Pixel(1);
TextBox textBox1 = new TextBox();
textBox1.ClientIDMode = ClientIDMode.Static;
textBox1.ID = "TextBox" + tbId.ToString();
tbId = tbId + 1;
tableCell2.Controls.Add(textBox1);
tableRow.Cells.Add(tableCell2);
break;
case 3: //第三列
TableCell tableCell3 = new TableCell();
tableCell3.BorderWidth = Unit.Pixel(1);
TextBox textBox2 = new TextBox();
textBox2.ClientIDMode = ClientIDMode.Static;
textBox2.ID = "TextBox" + tbId.ToString();
tbId = tbId + 1;
tableCell3.Controls.Add(textBox2);
tableRow.Cells.Add(tableCell3);
break;
case 4: //第四列
TableCell tableCell4 = new TableCell();
tableCell4.BorderWidth = Unit.Pixel(1);
DropDownList dropDownList = new DropDownList();
dropDownList.ClientIDMode = ClientIDMode.Static;
dropDownList.ID = "DropDownList" + i.ToString();
dropDownList.DataSource = PhotoAlbum();
dropDownList.DataBind();
tableCell4.Controls.Add(dropDownList);
tableRow.Cells.Add(tableCell4);
break;
}
}
TableUploadlayout.Rows.Add(tableRow);
}