473,587 Members | 2,548 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Situation:

Gridview is bound to an AccessDataSourc e 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, GridViewRowEven tArgs e)
{
TableCellCollec tion cells = e.Row.Cells;

if (e.Row.RowType == DataControlRowT ype.Header)
{
DataControlFiel dHeaderCell c =
(DataControlFie ldHeaderCell)ce lls[5];
BoundField bf = (BoundField)c.C ontainingField;

bf.HeaderText = "_PLACE";
}
}

Thanx for any suggestions !!
Charly

May 4 '06 #1
0 1123

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
953
by: John E. | last post by:
I have an ASP.NET datagrid with several bound columns. I need to make the header of some of these columns display a string that is generated from the code behind (i.e. a dynamic header). How is this done? I have tried with both a templatecolumn and boundcolumn. I thought it might be something like: HeaderText='<%#...
0
2643
by: Amber | last post by:
There are times when you will need to highlight or otherwise modify the contents of a particular DataGrid row-column value based upon the value in the column. In this example we will select the CompanyName, ContactName, and ContactTitle columns from the Customers table in the Northwind database. Whenever the value of ContactTitle equals...
0
1318
by: Andy Wang | last post by:
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...
4
3920
by: John E. | last post by:
I have an ASP.NET datagrid with several bound columns. I need to make the header of some of these columns display a string that is generated from the code behind (i.e. a dynamic header). How is this done? I have tried with both a templatecolumn and boundcolumn. I thought it might be something like: HeaderText='<%#...
0
3421
by: mlfblom | last post by:
Hi, I know I am not the only one struggling with the following, but so far I have not seen a solution. Problem: I have an asp.net 2.0 web page with a gridview which is bound to an accessdatasource. In my code-behind I want to be able to set the selectcommand of the datasource to a specific SQL string based on a user's input to retrieve...
3
1568
by: Ashton | last post by:
Hello, I have a GridView; once the page is loaded I can sort it just fine, I can sort it as many times as I would like, I can sort any of the columns. After clicking on Search and the GridView is updated with new data the sort does not work. I'm using C# and Ajax for the implementation, below is the code,
1
2016
by: =?Utf-8?B?SGFycnkgS2Vjaw==?= | last post by:
I have a GridView control with a few columns declared directly in the aspx file. I have found that if I remove the HeaderText property from all columns that the GridView handles state completely differently than if any of the columns has a value set for HeaderText. This sounds completely wrong to me. Has anyone ever heard of this? When no...
2
5575
by: sivagururaja | last post by:
Hi All, How can i sorting the Gridview Columns via the code behind. When i tried to sorting the column it doesn't work. SqlConnection con = new SqlConnection("Connection string"); con.Open(); SqlCommand cmd = new SqlCommand(str, con); SqlDataAdapter da = new SqlDataAdapter(cmd);
1
2070
by: Amit00 | last post by:
Hi, I have an ascx file with a gridview, and I need to change the header text of the gridview's column in the code-behind. Something like that: foreach (DataControlField col in GridView1.Columns) { col.HeaderText = GetString(col.HeaderText); } However, no matter where I place that code, the header texts return to their...
0
8215
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8347
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7973
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6626
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5718
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3844
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2358
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1454
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1189
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.