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

Customize grid column on the server

2 Answers 34 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sharon Eden
Top achievements
Rank 1
Sharon Eden asked on 26 Aug 2010, 10:41 AM

Hi,

I have a RadGrid that is programmatically bonded to a dataset from data access layer. I’m trying to change the width and header text of a column in the code behind and whatever I try, the columns collection is always empty. I’ve tried using the DataBound and the PreRender events and the collection is still empty. I also tried the ColumnCreated event, but the column in the event arguments has no header text.

How can I customize the column on run time?

I’m using 2010 Q2 controls.

Thanks,

Sharon.

2 Answers, 1 is accepted

Sort by
0
Accepted
Dimo
Telerik team
answered on 26 Aug 2010, 11:41 AM
Hi Sharon,

RadGrid.Columns contains the non-autogenerated columns, of which you have none.

Either use the RadGrid.MasterTableView.RenderColumns collection, or the ColumnCreated event to customize columns at runtime.

http://www.telerik.com/help/aspnet-ajax/grdusingcolumns.html

(see section "Customizing columns programmatically")

I recommend you to use ColumnCreated. The UniqueName of autogenerated columns is the same as their corresponding datafield.

The HeaderText property of a column can be empty if the column is not a GridBoundColumn, so you could check this first, before running other logic in the ColumCreated handler.

Best wishes,
Dimo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Sharon Eden
Top achievements
Rank 1
answered on 26 Aug 2010, 02:16 PM
Hi Dimo,

Thanks for the quick response.

I followed your advice, it works perfectly.

Thanks again,
Sharon.
Tags
Grid
Asked by
Sharon Eden
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Sharon Eden
Top achievements
Rank 1
Share this question
or