Reputation: 1521
Datagrid headers are automatically generated if we use class like
public Class student{ public int id {get; set;} public int name {get; set;} }
on generating list of class student to populate datagrid headers are automatically set.
My problem is that I dont have any static headers Im reading an .ods file uploaded by the users
How to make the first row of the dataTable as my datagrid header?
Upvotes: 0
Views: 1894
Reputation: 4361
Make use of DataGridColumn.HeaderText
property to set the header for each grid column. However since you want to use the first row of the dataTable for this, make sure there is at least one datarow available. before setting the datatable as the datasource you will have to remove the first row (as it is already been used as header). Refer to this MSDN Article
Upvotes: 1