January 18th, 2010, 03:01 AM
How to create column in datagrid and bind to datasource?
Iam new in c# programming, i was able to define columns for datagrid in designer and binding the datagrid to datatable and then it displays successfully.
but when trying to create the columns dynimcally and binding to the datatable iam getting an error
"At least one of the DataGridView control's columns has no cell template"
here is the code
column1.Width = 30;
column1.Name = "SN";
column1.DataPropertyName = "SN";
dgList.DataSource=dataTable; // it stops here. DataTable already defined and filled
what am i missing here ??
January 18th, 2010, 06:33 AM
Re: How to create column in datagrid and bind to datasource?
i found the solution in case of somebody needs
this line of code i came over it and not tried it of my idiocy
DgDoc.AutoGenerateColumns = false ;
i don't know what the relation between it and the error any way should be there.
thanks for the read
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!