Solved

Gridview HeaderText not changing

Posted on 2008-11-01
7
370 Views
Last Modified: 2011-08-18
Hello,

I have issue can't explain with a BulkEditGridView headers.

In design view I don't know what the headers will be...it changes depending on unit set in web.config.
So I leave the header as e.g.

<asp:TemplateField HeaderStyle-Font-Bold="false" HeaderText="ABC Input [UNIT]">

and populate on Page_Load correct headers on page_load like this
Me.Production.Columns(1).HeaderText = "ABC Input [metric unit]"

The headers aren't changing though on screen.

As a test I did in Page_Load before/after setting HeaderText:

System.Diagnostics.Debug.Print("Page_Load pre-setColumnTitles  HEADER: " & Me.Production.Columns(1).HeaderText())
Me.Production.Columns(1).HeaderText = "ABC Input [metric unit]"
System.Diagnostics.Debug.Print("Page_Load post-setColumnTitles HEADER: " & Me.Production.Columns(1).HeaderText())

the first debug line gives header as "ABC Input [UNIT]" - expected, this is what it is in design view
the next debug line gives header as "ABC Input [metric unit]" - expected, it has just been changed

HOWEVER, on the screen in browser the header says ABC Input [UNIT]  - it isn't changed.

Why would this be? This is the last bit of code on Page_Load

The BulkEditGridview is in a Menu_View. Interestingly if I go from the current view to another view and back again I find that the titles HAVE been changed

Thanks in advance for help on solving this
0
Comment
Question by:rwallacej
  • 4
  • 3
7 Comments
 
LVL 16

Expert Comment

by:Gyanendra Singh
ID: 22860308
did  AutoGenerateColumns="False" in your gridview .. if not please do that and bind your column and test
0
 

Author Comment

by:rwallacej
ID: 22865838
hi,
AutoGenerateColumns="False" was set already - so not fixed yet
thanks
0
 
LVL 16

Accepted Solution

by:
Gyanendra Singh earned 500 total points
ID: 22866059
do one thing try this in gridview rowdatabound event
protected virtual void RowDataBound(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
// here write your code
}
}
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

Author Comment

by:rwallacej
ID: 22871089
ok I thinkn almost here with this, on page display first time the columns are same as DESIGN view,
however on clicking "Add" to add a new row the column title changes. Not sure why it doesn't get set on first load though even though I use same code!
Protected Sub Production_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles Production.RowDataBound
            If (e.Row.RowType = DataControlRowType.Header) Then
                Me.Production_GasProdGrid.Columns(COLUMN_GasExport).HeaderText = "I hope this sets column!"
            End If
    End Sub

Open in new window

0
 
LVL 16

Expert Comment

by:Gyanendra Singh
ID: 22873324
first time did you bind your datagrid?  bind datagrid on page load ...
0
 

Author Comment

by:rwallacej
ID: 22874096
yes I do bind - the data is shown.

I ended up setting a label on page_load to what I want column headers to be & window.onload javascript to do search/replace. something strange in my case means its not working. I'll accept your answer as this would be way to do it in normal scenario - there must be something wrong with my page
0
 

Author Closing Comment

by:rwallacej
ID: 31512328
thank-you very much for your help
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question