DataGrid Header

  • Thread starter Thread starter Carl
  • Start date Start date
C

Carl

How can change the Header of a Datagrid?

for example: dpr_id change to dprno

thanks,
Carl
 
Hi, Carl,

If the DataGrid has AutoGenerateColumns set to false - you can set the
HeaderText for each of the columns to whatever you want.

If AutoGenerateColumns is true (it is true by default, that is - if you
don't specify it it is true) the header text is taken from the corresponding
column of the DataSource. So, if your DataSource is a DataTable (or a
DataView of a DataTable) you can alter the header texts by changing the
corresponding Columns' ColumnName property of the DataTable.

Hope this helps
Martin Dechev
ASP.NET MVP
 
If AutoGenerateColumns is true (it is true by default, that is - if you
don't specify it it is true) the header text is taken from the corresponding
column of the DataSource. So, if your DataSource is a DataTable (or a
DataView of a DataTable) you can alter the header texts by changing the
corresponding Columns' ColumnName property of the DataTable.

You don't have to touch the datasource. You can catch headers in ItemCreated
event and replace them there.

Eliyahu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top