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

Radgrid columns Caption

1 Answer 211 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rizwan Ansari
Top achievements
Rank 1
Rizwan Ansari asked on 03 Jan 2011, 08:49 AM
Hello Sir,

How can i access the column caption name in pageload and also i want to change on runtime the captions of columns text in editmode and pageload.

how can i do this.

thanks

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 03 Jan 2011, 10:02 AM
Hello Rizwan,

The following code snippet shows how to change the column header text in PageLoad event.
ASPX:
<telerik:GridBoundColumn UniqueName="FirstName" DataField="FirstName" HeaderText="FirstName">
 </telerik:GridBoundColumn>

C#:
protected void Page_Load(object sender, EventArgs e)
   {
           string header = (RadGrid1.MasterTableView.GetColumn("FirstName") as GridBoundColumn).HeaderText;//accessing column header text
           (RadGrid1.MasterTableView.GetColumn("FirstName") as GridBoundColumn).HeaderText = "new header"; //changing column header
    }

Give a try with the following code snippet to change the Column header text in edit mode.

protected void RadGrid1_PreRender(object sender, EventArgs e)
    {
        if (RadGrid1.EditIndexes.Count > 0)
        {
            RadGrid1.MasterTableView.GetColumn("FirstName").EditFormHeaderTextFormat = "new header text";
            RadGrid1.Rebind();
        }
    }

Thanks,
Princy.
Tags
Grid
Asked by
Rizwan Ansari
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or