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

[Solved] Clearing out the pagercontentcell

3 Answers 133 Views
Grid
This is a migrated thread and some comments may be shown as answers.
DogEars
Top achievements
Rank 2
DogEars asked on 29 Mar 2009, 04:34 AM
I've got the following code (from a project on the site to alphabetize the paging on the grid).

 If Session("AllData") Then 
            If TypeOf e.Item Is GridPagerItem Then 
                Dim pagerItem As GridPagerItem = CType(e.Item, GridPagerItem) 
                pagerItem.PagerContentCell.Controls.Clear() 
 
                Dim i As Integer 
                For i = 65 To 65 + 25 
                    Dim linkButton1 As New LinkButton() 
                    Dim lc As New LiteralControl() 
 
                    lc.Text = " " 
                    linkButton1.Text = "" + ChrW(i) 
 
                    linkButton1.CommandName = "alpha" 
                    linkButton1.CommandArgument = "" + ChrW(i) 
 
                    pagerItem.PagerContentCell.Controls.Add(linkButton1) 
                    pagerItem.PagerContentCell.Controls.Add(lc) 
                Next i 
            End If 
        End If 

I've got a session variable setup, depending on the type of search I either load up the alphabetic pager, or the standard one. The issue is that it always defaults to the standard controls, and as soon as I click a link in the pager it then switches to the alphabetic. And vice versa for the other search option.

So everything works, but I can't figure out how to force the grid pager to paint correctly without clicking on the pager itself.

Thanks.

3 Answers, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 01 Apr 2009, 10:26 AM
Hi DogEars,

The alphabetic grid pager is demonstrated (using two different approaches) on this online demo of the product:

http://demos.telerik.com/aspnet-ajax/grid/examples/programming/alphabeticpaging/defaultcs.aspx

and works as expected. Can you please outline the differences (presented in code snippets) between your case and those presented there? They can lead us to the source of the abnormality to eliminate it accordingly.

Best regards,
Sebastian
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
DogEars
Top achievements
Rank 2
answered on 01 Apr 2009, 12:57 PM
HI Sebastian,

The alphabetic paging works fine, there is no issue with that. The problem stems from the fact that I'm switching between paging alphabetically and with the standard prev/next 1,2,3 default.

You can see it in action here: http://beta.arizonanp.com/search.aspx

If you click on say, "show all nurse practitioners" button the code behind tells it to use the alphabetic paging, but you will see that the grid initially draws it with the standard paging. But if you click the paging area to change the page it will switch to the alphabetic. And if you did a search by specific city the grid will show the standard paging, since there are far fewer records to go through. And if they switch on the fly, the code behind changes the mode depending on the search.

There were too many records for people to page through when clicking show all, and the audience is not going to be skilled enough to use the filtering on the grid, so this seemed like the simplest way for the users. 

So if there is a way to clear that pager area/mode to force the grid to show the one I'm trying to use, I should be all set. I just couldn't find anything to make it happen.

Thanks for your time.
0
Sebastian
Telerik team
answered on 06 Apr 2009, 01:44 PM
Hello DogEars,

Can you please verify that you use advanced binding with NeedDataSource event handling for your grid and the code snippet from your previous post is executed inside the ItemCreated handler of the control? This should ensure that the controls inside the pager item will be recreated on each postback as expected and merely the alphabetic pager should be shown.

If the issue remains, please post the code from the problematic page using the 'Format Code Block' option in the forum editor (available in the top right corner of its toolbar). Thus I will examine your code implementation in detail and will get back to you with my findings.

Kind regards,
Sebastian
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
DogEars
Top achievements
Rank 2
Answers by
Sebastian
Telerik team
DogEars
Top achievements
Rank 2
Share this question
or