Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i having a datagrid.i want to add a new column and i wantsystem time in it,,how can i do that?

i could display values in the gird from database..now i want to add a new colum to the grid.the grid should contain system time
Posted
Updated 27-May-13 18:09pm
v2
Comments
Varun Sareen 27-May-13 3:22am    
what have you tried so far in your question context? where have you stuck??

Search google first and then try yourself then when you face problem then let us know
geo thomas 27-May-13 3:46am    
i could display values in the gird from database..now i want to add a new colum to the grid.the grid should contain system time
Basmeh Awad 28-May-13 4:40am    
Solution1 will work i have tried at my side

try this
C#
DataTable dt = new DataTable();
            dt.Columns.Add(new DataColumn("NewColumnName", typeof(DateTime)));
            dt.Rows.Add(DateTime.Now);
            dataGridView1.DataSource = dt;
 
Share this answer
 
v3
Comments
geo thomas 27-May-13 3:46am    
i could display values in the gird from database..now i want to add a new colum to the grid.the grid should contain system time
Basmeh Awad 27-May-13 3:54am    
try now
geo thomas 27-May-13 23:57pm    
Error 2 'System.Windows.Forms.DataGridView' does not contain a definition for 'Item' and no extension method 'Item' accepting a first argument of type 'System.Windows.Forms.DataGridView' could be found (are you missing a using directive or an assembly reference?)



am getting this error
Basmeh Awad 28-May-13 2:40am    
sorry...try now
As you need to show the current system time in grid view just select current date as getdate() and bind this column as we do to other column.

happy coding ..
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900