dwezil
asked on
Can I change the header text in my gridview?
This piece of code changes all my column headers to "test" but I need a way to change each column separately. Is there a way to adapt this code to make different headers for each column? I have five columns. Thanks
foreach (DataControlFieldCell cell in GridView1.HeaderRow.Cells)
cell.Text = "test";
Did you try: this.GridView1.Columns[5]. HeaderText = "whatever";
How to Change DataGrid Header Text?
http://www.c-sharpcorner.com/UploadFile/sd_patel/DataGridHeaderText11232005050843AM/DataGridHeaderText.aspx
http://www.c-sharpcorner.com/UploadFile/sd_patel/DataGridHeaderText11232005050843AM/DataGridHeaderText.aspx
try this...
GridView1.Columns[0].Heade rText = "test";
GridView1.Columns[1].Heade rText = "test1";
GridView1.Columns[0].Heade
GridView1.Columns[1].Heade
ASKER
Yea I've tried that too, get this error--
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentOutOfRangeE xception: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentOutOfRangeE
Parameter name: index
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks mate