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

[Solved] How to set EnableRangeFiltering in code-behind?

1 Answer 131 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jeanne
Top achievements
Rank 1
Jeanne asked on 19 Mar 2013, 04:10 PM
I cannot figure out how to set the EnableRangeFiltering and EnableTimeIndependentFiltering properties in my code-behind when I create my columns. GridBoundColumn does not have these properties, and I cannot cast a GridBoundColumn to a GridDateTimeColumn, which does.

1 Answer, 1 is accepted

Sort by
0
Jeanne
Top achievements
Rank 1
answered on 19 Mar 2013, 06:22 PM
I found out how to do it, but it is cumbersome.

First I tried creating a GridDateTimeColumn, setting those properties, then casting it to a GridBoundColumn to set the rest of the properties and add it to the grid's column collection, using the same code as for other columns. This worked fine until postback, when I would get an "unable to restore viewstate" error, probably due to the fact that the GridDateTimeColumn as added to the columns collection as a GridBoundColumn, so it didn't know how to restore it's properties correctly.

I finally found that if I added the GridDateTimeColumn as a GridDateTimeColumn to the grid's column settings collection, it would work.
Tags
Grid
Asked by
Jeanne
Top achievements
Rank 1
Answers by
Jeanne
Top achievements
Rank 1
Share this question
or