Hi,
I'm trying to programmatically set the paging behavior for my WHDG in code. I've used the CreateBehavior to create a paging behavior and then set my Paging behavior to enabled and set its page size, but despite setting these, there is no pager on the grid.
If I set the behavior via HTML it works fine, but through code it doesn't appear to work at all. I'm doing this on the Page_load before the datasource is tied to the grid. Also if I set the behavior in HTML and leave out the pagesize in the html and attempt to set it in the code behind, it just defaults to 8 per page, regardless of what I set.
Anyone run across this before or have a work around?
Hi,After you change the PageSize behavior in code, just call RefreshBehaviors() method off of the WHDG, and the PageSize should refresh.
Thanks,Olga
Olga,
Thanks for the help, that did succeed in causing the pagesize to change. But I've run across another issue, for some reason it causes my template controls to not find their Resource File's (Resx) text, removing the refresh behavior returns the text to the controls, but having it in causes it to disappear
Pearson.
Hi Pearson,
What RefreshBehaviors does is re-creates the behavior for the grid and the child grids so the PageSize can be propagated from the top level Band setting to all the children. If you are assigning the resource files to your template controls in code somehow, you’d have to do this after you called RefreshBehaviors. If that is not what if happening, can you provide a sample that reproduces the issue, so I further see what is happening to the resource files?
That seems to be the issue, as we have the resource file bind before the behavior refresh. I set up a work around to bind afterward.
Edit: I've gone through and tested more stuff after setting the refresh behavior and it appears it also removes the functionality of linkbuttons, does calling refreshbehavior require that I even re-add the onclick functionality? Removing the refreshbehavior call causes my templated linkbutton to work again.
Thanks,
Pearson