Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Chaning Column Text In Datagrid

Status
Not open for further replies.

LobsterSte

Programmer
Sep 2, 2006
9
ZA
How can I changed the text above every column in a datagrid?

I can't find anything about it in Msdn!

Please Help!
 
The default column name is set to the name coming from your DB. If you want to change it to something else then you can use the this:
Assume DataGrid name as 'dg', 'Emp_name' is default from DB, 'Employee Name' as custom name.
Code:
Dim dgTS As New DataGridTableStyle
Dim ColStyle As New DataGridTextBoxColumn
ColStyle.MappingName = "Emp_name"
ColStyle.HeaderText = "Employee Name"
dgTS.GridColumnStyles.Add(ColStyle)
dg.TableStyles.Add(dgTS)
You can do this at design time also so that you can specify all the fields as per your order.
Code:
<Columns>
<asp:BoundColumn DataField="Emp_name" HeaderText="Employee Name"></asp:BoundColumn>
</Columns>

Sharing the best from my side...

--Prashant--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top