change HeaderText of DataGrid in PreRender()

A

Andy Wang

I need change HeaderText of DataGrid in PreRender(). But it seems
doesn't work.
The code example like this:

Protected Overrides Sub OnPreRender(ByVal e As System.EventArgs)
grdPortals.Columns(1).HeaderText = "Title"
End Sub

I can see the value changed correctly when I was in debug mode, but it
doesn't show on the page. It always the original value.

When I try to change the same HeaderText of DataGrid, it works fine.
The code is below,

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
grdPortals.Columns(1).HeaderText = "Title"
End Sub

Does this means the HeaderText of DataGrid can only be changed in
Page_Load()? And cannot be changed in PreRender()? Is there any way to
change it in PreRender()?

Thanks,

Andy
 

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,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top