我有一个表格,我无法动态填充数据......它只倾向于显示最后一个表格单元格,其余行为空。虽然下拉列表似乎以正确的方式填充。
DataTable dtt1 = (DataTable)Session["dbasecolumns"];
int l = dtt1.Columns.Count;
string[] sqlcolumn = new string[l];
***for (int j = 0; j < dtt1.Columns.Count; j++)
{
sqlcolumn[j] = dtt1.Columns[j].ColumnName;
}
Session["excel"] = sqlcolumn;***
DropDownList drd = new DropDownList();
foreach (String colname in sqlcolumn)
{
drd.Items.Add(colname);
}
Table mytable = new Table();
mytable.Visible = true;
for (int rowctr = 0; rowctr < sqlcolumn.Length; rowctr++)
{
TableRow myrow = new TableRow();
mytable.Rows.Add(myrow);
for (int cellctr = 0; cellctr < 1; cellctr++)
{
TableCell mycell = new TableCell();
mycell.Controls.Add(drd);
myrow.Cells.Add(mycell);
}
***mytable.Rows.Add(myrow);***
}
Panel1.Controls.Add(mytable);
提前致谢