Change radGrid columns header

2 posts, 0 answers
  1. archimede
    archimede avatar
    103 posts
    Member since:
    Jul 2006

    Posted 07 Jun 2010 Link to this post

    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?
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 07 Jun 2010 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top