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

C

Charly

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
 
Joined
Feb 20, 2010
Messages
1
Reaction score
0
I encountered the same problem.
May I know if your problem has been fixed? What is the solution? Thanks.
 

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

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top