?
Solved

need to rename columns on datagrid...

Posted on 2004-04-15
4
Medium Priority
?
337 Views
Last Modified: 2008-03-17
I'm pulling a bunch of columns from a datareader into a datagrid.  Right now it is handling all the formatting.

I just want to rename the column headers and leave everything else alone.  What is the simplest way to do this?

Thanks,

gridREQ.DataSource = rdr
gridREQ.DataBind()
0
Comment
Question by:Weller0123
  • 2
4 Comments
 
LVL 28

Accepted Solution

by:
iboutchkine earned 2000 total points
ID: 10835310
If you have added a tablestyle to your grid, you can use the HeaderText
property of the columnstyle to change the column heading.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
         'change header for col 2
         Dim dgcs As DataGridColumnStyle =
Me.dataGrid1.TableStyles(0).GridColumnStyles(2)
         dgcs.HeaderText = "newtitle"
         Me.dataGrid1.Refresh()
End Sub

====================================
without tablestyles you can change the col name in the datatable and rebind the grid

ds.Tables.Item(0).Columns(1).ColumnName = "Test Caption"
 
0
 

Author Comment

by:Weller0123
ID: 10835507
Thanks...
0
 

Expert Comment

by:wmorales
ID: 10835603
On your query when you call your field:

SELECT HeaderThat_I_DontWant AS HeaderThat_I_Want
FROM MyTable

...  or you can go iboutchkine way but it won't change the grid it will change the table(tablestyle)... what he said.
0
 

Expert Comment

by:wmorales
ID: 10835650
Sorry I didn’t read iboutchkine last part that will change the grid as well... sorry.
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question