Click here to Skip to main content
15,921,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I have a datagridview and have bounded my datasource.
When the gridview is loaded, the column name follows the table attributes name.

Example:
catID desc catName

I want to rename the column to Cat ID, Description, Category Name

How do I do that?

Please help me.

Thanks in Advance.
Posted
Updated 9-Jun-11 21:46pm
v3
Comments
Dalek Dave 10-Jun-11 3:47am    
Edited for Grammar and Readability.
Ragi Gopi 10-Jun-11 3:53am    
ok sure..

Though I would prefer Prasad's solution but if you don't want to touch your query, you can try below solution:
Handle "ColumnAdded" event and based on the
e.Column.DataPropertyName 
property you can set
e.Column.HeaderText
property.
 
Share this answer
 
Comments
Ragi Gopi 10-Jun-11 3:28am    
thank u., i will try this too...
Dalek Dave 10-Jun-11 3:47am    
Good Call.
Here is One Solution For That...

Use Alias Name for each Column Name
Inside Query that U R going to execute

Like This..

Select catID as Cat ID, desc as Description, catName as Category Name from UrTable
 
Share this answer
 
Comments
RakeshMeena 10-Jun-11 3:08am    
My 5! Best solution, but if you don't want to modify your query then see my answer.
Dalek Dave 10-Jun-11 3:47am    
Good Answer.
parmar_punit 11-Jun-11 8:46am    
good ans, my 5

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