This is a migrated thread and some comments may be shown as answers.

[Solved] Replacing the e.Column.Header in OnAutoGeneratingColumn

2 Answers 125 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
NR
Top achievements
Rank 1
NR asked on 01 Aug 2011, 10:41 PM
I have extended the RadGridView in my own code by creating a class and inheriting RadGridView.

I have created the RadGridViewEx (as I've called it) on my MainPage.xaml and have it set to AutoGenerateColumns=True.

The problem I am running into is that my database columns have a % sign in their name, and it's not binding the property correctly, so I've done a .Replace("%", "REPLACE_PCT") on the column that is coming from my WCF service and I'm attempting to change the e.Column.Header back to the format using .Replace("REPLACE_PCT", "%") in the OnAutoGeneratingColumn event that I've overridden and it doesn't seem to have any affect on the GridView.

I can actually set up any AutoGenerated columns and attempt to change the e.Column.Header and it will have no affect on the UI end.

To demonstrate this, set up a RadGridView that has AutoGenerateColumns set to True, and bind it to a collection of any custom object (like Person for example). Set up an override on OnAutoGeneratingColumns event and attempt to change e.Column.Header to some new value before calling base.OnAutoGeneratingColumn(e);. I would expect to see my new Header as part of the GridView but the UI stays the same and matches the UniqueName (property name) of my object.

Am I doing something wrong?

2 Answers, 1 is accepted

Sort by
0
Accepted
Maya
Telerik team
answered on 02 Aug 2011, 06:55 AM
Hello Nathan,

I have tested the scenario, but I was not able to get the behavior you described. May you take a look at the sample attached to verify whether it corresponds to your settings or I am missing something ? 


Kind regards,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
NR
Top achievements
Rank 1
answered on 02 Aug 2011, 05:43 PM
Thank you for your assistance.

After checking my code again I realized that I was actually adding a Tooltip somewhere else and was re-setting the Header Text using that new Textblock. It was not showing up right because of the Tooltip I was adding.

Sorry for the confusion.. Your assistance caused me to go back and comment out all my code and just try what you had posted.. and to my amazement it worked... *sigh*

Sorry again for the confusion.
Tags
GridView
Asked by
NR
Top achievements
Rank 1
Answers by
Maya
Telerik team
NR
Top achievements
Rank 1
Share this question
or