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

[Solved] How can I Modify HeaderText but keep Ajax sorting?

3 Answers 165 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 23 Jul 2009, 10:49 AM
When I followed the procedure below to dynamically modify the HeaderText in a column I found that the sorting feature for that column was lost.


Is there a fix for the problem.

Note: I've added more detail on this in the thread for the actual link above.

3 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 23 Jul 2009, 11:03 AM
Hello Mark,

 When you enable sorting in the grid then you will have a LinkButton in the HeaderItem for a column. So you would have to access the button and then customize the text for the button as shown below:
c#:
protected void RadGrid2_ItemCreated(object  sender, GridItemEventArgs e) 
       if (e.Item is GridHeaderItem) 
       { 
          GridHeaderItem headerItem = e.Item as GridHeaderItem; 
          LinkButton button = headerItem["ProductName"].Controls[0] as LinkButton; 
          button.Text = "My customized text"
       } 

Thanks
Shinu.
0
Mark
Top achievements
Rank 1
answered on 23 Jul 2009, 12:33 PM
Thanks. That worked but I used the ItemDataBound event instead.
0
Shinu
Top achievements
Rank 2
answered on 24 Jul 2009, 03:59 AM
Hi Mark,

You may also refer the following help article which explains the major differences between ItemCreated and ItemDataBound events.
Distinguishing the major differences between ItemCreated and ItemDataBound events

Thanks
Shinu
Tags
Grid
Asked by
Mark
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Mark
Top achievements
Rank 1
Share this question
or