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

Programmatically add GridTemplateColumn

1 Answer 95 Views
Grid
This is a migrated thread and some comments may be shown as answers.
RvdGrint
Top achievements
Rank 1
RvdGrint asked on 28 Feb 2012, 01:29 PM
Hello,

I've a grid on a dynamically loaded UserControl. From the code-behind I'm adding serveral columns to the existing column collection. This happens on Page_Init. Now when a postback occurs the columns are added again and when the viewstate is loaded the columns from a previous creation are added also. So every postback my column collection grows.
I only want to recreated the columns on Page_Init manually and exclude them from ViewState. How can I force this?

Regards,
  JosM

1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 28 Feb 2012, 03:31 PM
Hi JosM,

To avoid this erroneous behaviour you should set the EnableColumnViewState property to False, so that the grid knows that the columns may vary at some stage of the page lifecycle. Please refer to the help article below for more information on the matter:
http://www.telerik.com/help/aspnet-ajax/grid-changing-structure-dynamically.html

Regards,
Pavlina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
RvdGrint
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Share this question
or