Solved

Dynamically Changing Template Column HeaderText   When????? Example Please

Posted on 2004-09-03
5
986 Views
Last Modified: 2008-03-10
I am using asp Net C#.  I have a datagrid and I am using template columns.

the aspx  code looks like

                                                <asp:TemplateColumn >
                                                      <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle"></ItemStyle>
                                                      <HeaderTemplate>
                                                            <asp:label id="Label18" runat="server" Font-Names="Arial,Times New Roman,Verdana" Font-Size="10pt"
                                                                  Width="50 px" ForeColor="White" BackColor="#6495ed">Distance</asp:label>
                                                      </HeaderTemplate>

                                                      <ItemTemplate>
                                                            <asp:Label id="lblLabel18" Width="50" Text='<%# DataBinder.Eval(Container.DataItem,"Distance", "{0:F5}") %>' Runat="server">
                                                            </asp:Label>
                                                      </ItemTemplate>
                                                </asp:TemplateColumn>



In the aspx.cs code
I want to change the value of the header from"Distance" to something else based on the a value in the database.  

I have tried all your examples as you can see here :

                  dg.Columns[7].HeaderText = "MY TEST";

But the column still shows me "DISTANCE".

I have put the change in before, and after the databind but I still get "DISTANCE".

I am using C# with asp.net.  Many thanks in advance.
0
Comment
Question by:kathywargo
  • 2
5 Comments
 
LVL 4

Accepted Solution

by:
Sicos earned 125 total points
ID: 11977776
I think you need to disable the auto making of columns in the datagrid.

Greetings,

Sicos
0
 
LVL 4

Expert Comment

by:Sicos
ID: 12495345
I did give the solution...
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…

726 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