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

setting pagerstyle mode in code-behind

4 Answers 230 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Albert Shenker
Top achievements
Rank 1
Veteran
Iron
Albert Shenker asked on 13 Jan 2014, 05:17 PM
I would like to set the grid PagerStyle mode in code behind in order to display different pagers depending on various criteria (namely the available width expected on the particular screen the grid displays on). The criteria I will base this decision on are all available in code behind, but I can't seem to get the setting of the grid PagerStyler.Mode property to work. It seems to ignore anything I set in code behind and go with what is specified in the grid declaration. I have tried setting this in page load prior to the grid being bound and also in the item created event. Can you let me know how I can set the PagerStyle mode in code behind?

Thanks.

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 14 Jan 2014, 07:12 AM
Hi Albert Shenker,

Please try the following C# code snippet to set the PagerStyle Mode from code behind.

C#:
RadGrid1.PagerStyle.Mode = GridPagerMode.NextPrev;


Thanks,
Shinu.
0
Albert Shenker
Top achievements
Rank 1
Veteran
Iron
answered on 14 Jan 2014, 01:54 PM
As I mentioned.. that's the code I am using. I have tried it prior to binding and also in ItemCreated. The setting is ignored and the value specified in the declaration is always used.
0
Shinu
Top achievements
Rank 2
answered on 15 Jan 2014, 04:11 AM
Hi Albert Shenker,

The code to set the PagerStyle depends on where you have declaratively set it. If its inside the MasterTableView please use the following code snippet:

ASPX:
<MasterTableView>
<PagerStyle Mode="NumericPages" />

C#:
RadGrid1.MasterTableView.PagerStyle.Mode = GridPagerMode.NextPrev;

Or if its outside the MasterTableView please use the following code snippet:

ASPX:
<PagerStyle Mode="NumericPages" />
<MasterTableView>

C#:
RadGrid1.PagerStyle.Mode = GridPagerMode.NextPrev;

Thanks,
Shinu
0
Albert Shenker
Top achievements
Rank 1
Veteran
Iron
answered on 15 Jan 2014, 02:39 PM
That took care of it. Thanks.
Tags
Grid
Asked by
Albert Shenker
Top achievements
Rank 1
Veteran
Iron
Answers by
Shinu
Top achievements
Rank 2
Albert Shenker
Top achievements
Rank 1
Veteran
Iron
Share this question
or