Click here to Skip to main content
16,016,580 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
the column name configured in the database.
C# windows form 


What I have tried:

DataTable dt = new DataTable();

DataColumn col = new DataColumn();
 col.DataType = typeof(string);
col.Caption = "displayname"  
col.ColumnName = "fieldname";
dt.Columns.Add(col); 

gv.datasource = dt;

the column still shows "fieldname"
Posted
Updated 26-Sep-17 22:33pm
Comments
Graeme_Grant 27-Sep-17 4:16am    
What is the question?

1 solution

try HeaderText [^] property

DataTable dt = new DataTable();
           DataColumn col = new DataColumn();
           col.DataType = typeof(string);
           col.ColumnName = "fieldname";
           dt.Columns.Add(col);
           dt.Rows.Add(1);
           gv.DataSource = dt;
           gv.Columns[0].HeaderText = "displayname";
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900