【发布时间】:2012-05-03 12:16:20
【问题描述】:
我正在使用 C# 来发展我的技能。我正在尝试我在网上找到的教程:http://geekswithblogs.net/dotNETvinz/archive/2009/03/17/dynamically-adding-textbox-control-to-aspnet-table.aspx 但是当我尝试代码并添加 Generate table 方法时,它告诉我找不到Table table = new Table(); 的类型或命名空间名称.. 有谁知道我应该为此使用的命名空间。这是剩下的代码:
private void GenerateTable(int colsCount, int rowsCount)
{
//Creat the Table and Add it to the Page
Table table = new Table();
table.ID = "Table1";
Page.Form.Controls.Add(table);
// Now iterate through the table and add your controls
for (int i = 0; i < rowsCount; i++)
{
TableRow row = new TableRow();
for (int j = 0; j < colsCount; j++)
{
TableCell cell = new TableCell();
TextBox tb = new TextBox();
// Set a unique ID for each TextBox added
tb.ID = "TextBoxRow_" + i + "Col_" + j;
// Add the control to the TableCell
cell.Controls.Add(tb);
// Add the TableCell to the TableRow
row.Cells.Add(cell);
}
// Add the TableRow to the Table
table.Rows.Add(row);
}
}
任何帮助将不胜感激,谢谢
【问题讨论】:
标签: c# .net visual-studio-2010 dynamic