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

Setting the headerText in grid bound to an arraylist

1 Answer 62 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ChrisWalker
Top achievements
Rank 1
ChrisWalker asked on 09 Sep 2008, 09:52 PM
Hello,
I need to bind a grid to an arraylist that I create. Using the online demos on your site I was able to quickly show a grid bound to the arraylist using the TestListItem class that has 2 properties: A and B. However the  grid shows the column headers as 'A' and 'B'. I need to set these HeaderText values from a resource file (localization) so I cannot change the propertyNames in the TestListItem class.
I thought I could do it in the DataBound handler but could not find the right place to set these values.

 

1 Answer, 1 is accepted

Sort by
0
ChrisWalker
Top achievements
Rank 1
answered on 10 Sep 2008, 08:14 PM
I figured this out. In case someone else needs to do this, here are the steps-

Using the telerik example for binding to a grid with nullable objects:
http://www.telerik.com/help/aspnet-ajax/grdbindingtonullableobjects.html

1- set the grid's AutoGenerateColumns="false" or you will have duplicate columns generated.

2- Create databound columns with the DataField= a property in the arraylist. Using the telerik example the TestListItem contains 2 string properties: A and B. So a gridbound column for property A would be:

<telerik:GridBoundColumn DataField="A" UniqueName="A".......

Now to set the headerText for the column, insert a meta:resourceKey= .
Ex:

<

telerik:GridBoundColumn DataField="A" UniqueName="A" meta:resourceKey="GridColumnA"></telerik:GridBoundColumn>

In the local resx file for this page I have an entry named GridColumnA.HeaderText = "Column A".

ASP.Net will then resolve the localization as well as set the HeaderText for this column.
Tags
Grid
Asked by
ChrisWalker
Top achievements
Rank 1
Answers by
ChrisWalker
Top achievements
Rank 1
Share this question
or