vikki_logs
vikki_logs

Reputation: 1521

How to make the first row of the dataTable as my datagrid header? -ASP.NET

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

Answers (1)

Prashanth Thurairatnam
Prashanth Thurairatnam

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

Related Questions