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. Advertisements

  2. Charly

    hkjaja

    Joined:
    Feb 20, 2010
    Messages:
    1
    Likes Received:
    0
    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. Advertisements

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. Ben Miller [msft]

    Re: Code Behind vs. no code behind: error

    Ben Miller [msft], Jun 27, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    826
    Alphonse Giambrone
    Jun 28, 2003
  2. Andy Wang
    Replies:
    0
    Views:
    578
    Andy Wang
    May 12, 2004
  3. John E.
    Replies:
    4
    Views:
    4,912
    John E.
    Oct 14, 2004
  4. Øyvind Isaksen

    Change HeaderText in datagrid

    Øyvind Isaksen, Nov 6, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    4,195
    Eliyahu Goldin
    Nov 6, 2005
  5. Sharon
    Replies:
    1
    Views:
    1,556
    Kevin Frey
    Dec 1, 2006
  6. =?Utf-8?B?SGFycnkgS2Vjaw==?=

    Should HeaderText change the behavior of a GridView?

    =?Utf-8?B?SGFycnkgS2Vjaw==?=, Feb 13, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    528
    Teemu Keiski
    Feb 14, 2007
  7. John

    Non-code behind to code behind

    John, Feb 19, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    719
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Feb 19, 2007
  8. john

    Griview cells Text Special Characters

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