change HeaderText of DataGrid in PreRender()

Discussion in 'ASP .Net' started by Andy Wang, May 12, 2004.

  1. Andy Wang

    Andy Wang Guest

    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
    Andy Wang, May 12, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Øyvind Isaksen

    Change HeaderText in datagrid

    Øyvind Isaksen, Nov 6, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    3,929
    Eliyahu Goldin
    Nov 6, 2005
  2. Joe Rattz

    HeaderText changed during PreRender does not render

    Joe Rattz, Nov 6, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    137
    Joe Rattz
    Nov 6, 2003
  3. Andy Wang

    change HeaderText of DataGrid in PreRender().

    Andy Wang, May 12, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    6
    Views:
    415
    Eliyahu Goldin
    May 16, 2004
  4. Ravi Gudlavalleti

    How do I change the headertext of a datagrid column programmatically

    Ravi Gudlavalleti, Jun 17, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    195
    Ken Cox [Microsoft MVP]
    Jun 18, 2004
  5. Sangra M via .NET 247

    Change HeaderText of datagrid after binding

    Sangra M via .NET 247, Mar 14, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    284
    Sylvain Lafontaine
    Mar 14, 2005
Loading...

Share This Page