Can not change Headertext with sorting ability in Griview from code behind

Discussion in 'ASP .Net' started by Charly, May 4, 2006.

  1. Charly

    Charly Guest

    Situation:

    Gridview is bound to an AccessDataSource declaratively.
    The 'Auto-generate fields' is on since the DataSource will use a
    crosstab query where some columns are known beforehand and others are
    not.
    The AllowSorting is set declaratively to true.

    Now, for the known columns I want to change the ColumnHeader text
    depending on some language settings. Using the .Text property works but
    the header looses the sort ability (eg. No hyperlink around the header
    text). Using the HeaderText property doesn't seem to be doing
    anything!!

    Code:

    protected void OnRowDataBound(object sender, GridViewRowEventArgs e)
    {
    TableCellCollection cells = e.Row.Cells;

    if (e.Row.RowType == DataControlRowType.Header)
    {
    DataControlFieldHeaderCell c =
    (DataControlFieldHeaderCell)cells[5];
    BoundField bf = (BoundField)c.ContainingField;

    bf.HeaderText = "_PLACE";
    }
    }

    Thanx for any suggestions !!
    Charly
     
    Charly, May 4, 2006
    #1
    1. Advertising

  2. Charly

    hkjaja

    Joined:
    Feb 20, 2010
    Messages:
    1
    I encountered the same problem.
    May I know if your problem has been fixed? What is the solution? Thanks.
     
    hkjaja, Feb 20, 2010
    #2
    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. Andy Wang
    Replies:
    0
    Views:
    501
    Andy Wang
    May 12, 2004
  2. John E.
    Replies:
    4
    Views:
    4,691
    John E.
    Oct 14, 2004
  3. Øyvind Isaksen

    Change HeaderText in datagrid

    Øyvind Isaksen, Nov 6, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    3,980
    Eliyahu Goldin
    Nov 6, 2005
  4. Sharon
    Replies:
    1
    Views:
    1,422
    Kevin Frey
    Dec 1, 2006
  5. john

    Griview cells Text Special Characters

    john, Oct 12, 2007, in forum: ASP .Net Web Controls
    Replies:
    6
    Views:
    775
    Steven Cheng[MSFT]
    Oct 17, 2007
Loading...

Share This Page