创建一个动态表 [英] Creating a dynamic table
问题描述
IM用C#致力于发展自己的技能。我想,我已经在网上<一个发现了一个教程href="http://geekswithblogs.net/dotNETvinz/archive/2009/03/17/dynamically-adding-textbox-control-to-aspnet-table.aspx" rel="nofollow">http://geekswithblogs.net/dotNETvinz/archive/2009/03/17/dynamically-adding-textbox-control-to-aspnet-table.aspx但是当我尝试在code,并添加生成表的方法,它告诉我,类型或表的表命名空间名称=新表();
无法发现..没有人知道我应该用这个东西命名空间。这是在code中的其余部分。
im working with c# to develop my skills. i am trying a tutorial that i have found online http://geekswithblogs.net/dotNETvinz/archive/2009/03/17/dynamically-adding-textbox-control-to-aspnet-table.aspx but when i try the code and add the Generate table method it tells me that the type or the namespace name for Table table = new Table();
could not be found.. does anyone know what namespace i should use for this. this is the rest of the code.
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);
}
}
任何帮助将是非常美联社preciated感谢
any help would be much appreciated thanks
推荐答案
请确保您要导入的命名空间表的 MSDN参考
Make sure that you are importing the namespace for table MSDN Ref
有一个
using System.Web.UI.WebControls;
在你的文件的开头?
at the top of your file?
这篇关于创建一个动态表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!