In this task,the csv file has retreived and it viewed by using datagrid. but now how we can take a specified header name from the datatable??

Recommended Answers

All 3 Replies

Do you mean you want to retrieve the name of a column in a DataTable?

If yes, DataTable.Columns[ColumnIndex].ColumnName return the name of the column specified by 'ColumnIndex'.

For example, to retrieve the name of the 4th column from the DataTable object 'dtEmp',

String colName = dtBooks.Columns[3].ColumnName ;

Note that the column index starts with 0.

Can you elaborate?

Does the first row in the csv contain the column names?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.