Hi,
I want your help to the following problem.
I have a grid which calls an OnNeedDataSource event to fetch data. The grid columns and data are automatically created based on the list(Of Object) I pass to the grid datasource. The problem I have is that I want to REMOVE and RENAME some columns from the grid but I want to maintain the way the grid works now. How can I rename the column headers of the grid or make them visible false from code behind? From the aspx file I can't do anything because in the ...<MasterTableView><Columns>... tag I don't include any data.
Thanks
George
I want your help to the following problem.
I have a grid which calls an OnNeedDataSource event to fetch data. The grid columns and data are automatically created based on the list(Of Object) I pass to the grid datasource. The problem I have is that I want to REMOVE and RENAME some columns from the grid but I want to maintain the way the grid works now. How can I rename the column headers of the grid or make them visible false from code behind? From the aspx file I can't do anything because in the ...<MasterTableView><Columns>... tag I don't include any data.
Thanks
George
5 Answers, 1 is accepted
0
Hi George,
You can customize the properties of auto-generated columns at runtime by providing a handler for the grid's ColumnCreated event. In the event handler, cast the column to the appropriate type and set its attributes. Review this help topic for additional information.
Greetings,
Pavlina
the Telerik team
You can customize the properties of auto-generated columns at runtime by providing a handler for the grid's ColumnCreated event. In the event handler, cast the column to the appropriate type and set its attributes. Review this help topic for additional information.
Greetings,
Pavlina
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0

George
Top achievements
Rank 1
answered on 07 Jan 2011, 04:09 PM
Ok Pavlina thanks for your reply. I have try the following but I m getting an error.
Error : An unhandled exception of type 'System.StackOverflowException' occurred in System.Web.dll
Can you help me with that please?
Protected Sub sampleGrid_ColumnCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridColumnCreatedEventArgs) Handles sampleGrid
.ColumnCreated
If (e.Column.UniqueName = "Sample Name") Then
Dim boundColumn As GridBoundColumn = CType(e.Column, GridBoundColumn)
boundColumn.HeaderText = "test"
End If
sampleGrid.Rebind()
End Sub
<
telerik:RadGrid
runat
=
"server"
ID
=
"sampleGrid"
OnNeedDataSource
=
"sampleGrid_NeedDataSource"
Width
=
"375px"
Skin
=
"Telerik"
AllowSorting
=
"true"
AllowMultiRowSelection
=
"true"
OnRowDrop
=
"sampleGrid_RowDrop"
>
<
MasterTableView
DataKeyNames
=
"Id"
Width
=
"100%"
TableLayout
=
"Fixed"
>
<
Columns
></
Columns
>
</
MasterTableView
>
<
ClientSettings
AllowRowsDragDrop
=
"True"
>
<
Selecting
AllowRowSelect
=
"True"
EnableDragToSelectRows
=
"false"
/>
<
Scrolling
AllowScroll
=
"true"
UseStaticHeaders
=
"true"
ScrollHeight
=
"320px"
/>
</
ClientSettings
>
</
telerik:RadGrid
>
Error : An unhandled exception of type 'System.StackOverflowException' occurred in System.Web.dll
Can you help me with that please?
0
Hello George,
Please try removing the following line:
from the ColumnCreated event handler and let me know if it makes any difference.
Best wishes,
Pavlina
the Telerik team
Please try removing the following line:
sampleGrid.Rebind()
from the ColumnCreated event handler and let me know if it makes any difference.
Best wishes,
Pavlina
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0

George
Top achievements
Rank 1
answered on 08 Jan 2011, 12:55 PM
Ok, I remove sampleGrid.Rebind(), the page is working fine but I still don't know how to rename the grid headers. Is the way I am trying correct?
0
Hi George,
When you have sorting turned on, the text for each column is rendered as a link button. So you would have to access the LinkButton and then customize the text. Refer to the following link for more information:
Localizing the grid headers
All the best,
Pavlina
the Telerik team
When you have sorting turned on, the text for each column is rendered as a link button. So you would have to access the LinkButton and then customize the text. Refer to the following link for more information:
Localizing the grid headers
All the best,
Pavlina
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.