3

I am retrieving table from data base and storing in data table.

I need to change column name into new column name in data table I tried below code but its not changing..where I made mistake....

             foreach (DataColumn column in obj_dt.Columns)
             column.Caption = column.ColumnName.Replace("Tax","new tax");

             foreach (DataGridViewColumn gridColumn in dataGridView_dataGridView_curt_Prd_Dtls.Columns)
             gridColumn.HeaderText = obj_dt.Columns[gridColumn.HeaderText].Caption;

             dataGridView_dataGridView_curt_Prd_Dtls.DataSource = obj_dt;
Amit Verma
  • 40,709
  • 21
  • 93
  • 115
Happy
  • 63
  • 2
  • 8

1 Answers1

0

Please Check the link below will helps you in finding your answer

How to rename the datatable column name without losing the data?

Why DataColumn.Caption doesn't work?

Community
  • 1
  • 1
Sajid Hussain
  • 63
  • 2
  • 10