Change headertext dynamically populated gridview

  • Thread starter Thread starter Sharon
  • Start date Start date
S

Sharon

Hello All,

I have a gridview control in webform which is dynamically populated on
page startup with a query. I was trying to change the header text for
the columns and also set wrap to false. i have four columns in
gridview. Any suggestions guys

This is what i used but i keep getting error
Private Sub changestyle()
GridView1.Columns(1).HeaderText = "First Name"
End Sub

Error
Index was out of range. Must be non-negative and less than the size of
the collection.
Parameter name: index
 
What do you mean by "Dynamically Populated". Do you mean the colums are
automatically generated?

Assuming that's the case, you could just manually declare all the columns
for the gridview instead, rather than relying on the Auto Generate
functionality.

Another possibility is to hook a handler onto Pre-Render of GridView, but
I'm not sure if the Columns will have been generated by then, or even if the
auto-generated columns are accessible in that manner.
 
Back
Top