Change headertext dynamically populated gridview

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
 
K

Kevin Frey

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top