2010-06-01 46 views
0

我已經創建了三個字段,即TimeTask,TaskItem和Count(用戶數)的數據表。 {「12:30 AM-01:00AM」,T1,3}。是否可以在現有DataTable中動態插入行(不使用DataSource)?

 dataTable.Columns.Add("Task Time", typeof(string)); 
     dataTable.Columns.Add("Task", typeof(string)); 
     dataTable.Columns.Add("Count", typeof(int)); 

     dataTable.Rows.Add("12:00AM-12:15AM", "T1", 6); 
     dataTable.Rows.Add("12:45AM-01:00AM", "T1", 5);        dataTable.Rows.Add("01:00AM-01:15AM", "T1", 1); 
     dataTable.Rows.Add("01:15AM-01:30AM", "T2", 4); 
     dataTable.Rows.Add("01:30AM-01:45AM", "T2", 9);    
     GridView1.DataSource = dataTable; 
     GridView1.DataBind(); 



    In this there is no task for the TimeTask "12:15AM-12:30AM" and "12:30AM-12:45AM" yet the TimeTask should be inserted as,   

TimeTask TaskItem計數
12:00 AM-12:15AM T1 6
12:15 AM-12:30AM - -
12:30 AM-12:45AM - -
12:45 AM-01 00:00 T1 5
01:00 AM-01:15AM T1 1
1時15 AM-01:30AM T2 4
01:30 AM-01:45AM T2 9

如何清潔香港失蹤ř OWS?是否可以動態地在現有的數據表中插入行(不使用數據源)在這個scenario.pls help.Thanks :-)

回答

0
DataRow dr = dt.NewRow(); 
dr["Task Time"] = ....; 
dr["Task"] = ....; 
dr["Count"] = ....; 
dt.Rows.Add(dr); 

應該做的伎倆。

+0

它工作正常.... thanx很多:) – user354547 2010-06-07 11:11:39

+0

你可以驗證我的答案... – 2010-06-07 13:10:31

相關問題