2012-08-01 53 views
0

我有一个table与列totalnames。该表有10行。c#中的动态数据库行表

现在我想为我的网页中的复选框动态地创建这10行的表。请发送一些很好的例子。

+0

你应该先试用一下你的自我,SO只有当你在某个时候卡住时才会帮助你。记住上帝帮助那些帮助他们自我的人。 – yogi 2012-08-01 07:29:20

回答

0

示例代码:动态创建表,添加cloumn,添加行

(1) create a new DataTable  
    DataTable dt = new DataTable ("Table_AX");  

(2) Add columns to the DataTable  
    // Method 1  
    dt.Columns.Add ("column0", System.Type.GetType ("System.String"));  
    // Method 2  
    DataColumn dc = new DataColumn ("column1", System.Type.GetType ("System.Boolean"));  
    dt.Columns.Add (dc);  

(3) to add rows to the DataTable  
    // Initialize the row  
    DataRow dr = dt.NewRow();  
    dr ["column0"] = "AX";  
    dr ["column1"] = true;  
    dt.Rows.Add (dr);  
    // Doesn't initialize the row  
    DataRow dr1 = dt.NewRow();  
    dt.Rows.Add (dr1);  

如果你想复制数据表中包括的数据尽量

DataTable dtNew = dt.Copy();