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

Change radGrid columns header

1 Answer 253 Views
Grid
This is a migrated thread and some comments may be shown as answers.
archimede
Top achievements
Rank 1
archimede asked on 07 Jun 2010, 11:07 AM
I'd like to programmatically change the radgrid column header (depending on user culture). In my database I have the translation of words to use for each column uniquename.
To do the translation I use the radgrid_columncreated event.

    protected void RadGridTraduzione_ColumnCreated(object sender, GridColumnCreatedEventArgs e)  
    {  
        string c = e.Column.UniqueName;  
 
        GridColumn boundColumn = e.Column as GridColumn;   
 
        if (boundColumn.UniqueName == "Maschera")  
        {  
            switch (((SessionInformation)Session["sessionData"]).IdCultura)  
            {  
                case 1:  
                    //boundColumn.HeaderText = ...;  
                    break;  
                case 2:  
                    //boundColumn.HeaderText = ...;  
                    break;  
                case 3:  
                    break;  
                case 4:  
                    break;  
            }  
        }  
    } 

I have the problem that e.Column.UniqueName is "ExpandColumn" for all my bound data columns, how can I access the .aspx specified UniqueName?

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 07 Jun 2010, 01:06 PM
Hello Archimede,

Try the following code snippet in PreRender event to change the HeaderText.

C#:
protected void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
       foreach (GridColumn col in RadGrid1.Columns) 
        { 
            if (col.UniqueName == "ColumnUniqueName"
                col.HeaderText = "new headertext"
        } 
       RadGrid1.Rebind(); 
    } 

Regards,
Shinu.
Tags
Grid
Asked by
archimede
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or