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

[Solved] Pager not displaying on initial page load

1 Answer 90 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Daniel Caves
Top achievements
Rank 1
Daniel Caves asked on 22 Sep 2009, 03:17 PM
On every RadGrid in my web application, I am having an issue where the pager is not displaying on the initial page load.  After doing a post back, and rebinding the data, the pager shows up.  Code for one of my grids is below:

<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False"  
            DataSourceID="SqlDataSource1" GridLines="None" AllowPaging="True"  
            Skin="Black"
            <MasterTableView DataSourceID="SqlDataSource1" PageSize="15"
            <RowIndicatorColumn> 
            <HeaderStyle Width="20px"></HeaderStyle> 
            </RowIndicatorColumn> 
 
            <ExpandCollapseColumn> 
            <HeaderStyle Width="20px"></HeaderStyle> 
            </ExpandCollapseColumn> 
                <Columns> 
                    <telerik:GridBoundColumn DataField="Name" HeaderText="Name"  
                        SortExpression="Name" UniqueName="columnName"
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="Address1" HeaderText="Address1"  
                        SortExpression="Address1" UniqueName="columnAddress1"
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="Address2" HeaderText="Address2"  
                        SortExpression="Address2" UniqueName="columnAddress2"
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="City" HeaderText="City"  
                        SortExpression="City" UniqueName="columnCity"
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="State" HeaderText="State"  
                        SortExpression="State" UniqueName="columnState"
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="Zip" HeaderText="Zip"  
                        SortExpression="Zip" UniqueName="columnZip"
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="Phone" HeaderText="Phone"  
                        SortExpression="Phone" UniqueName="columnPhone"
                    </telerik:GridBoundColumn> 
                </Columns> 
                <PagerStyle Mode="NumericPages" /> 
            </MasterTableView> 
        </telerik:RadGrid> 
         
        <asp:SqlDataSource ID="SqlDataSource1" 
            ConnectionString="<%$ ConnectionStrings:TLRGCPortal %>" 
            ProviderName="System.Data.SqlClient" SelectCommand="spGetLocations"  
            runat="server" SelectCommandType="StoredProcedure"></asp:SqlDataSource> 

An example of a rebinding that makes the pager display is below:

        protected void btnClear_Click(object sender, EventArgs e) 
        { 
            txtSearch.Text = ""
            SqlDataSource1.SelectCommand = "spGetEmployeeDirectory"
            SqlDataSource1.SelectCommandType =  SqlDataSourceCommandType.StoredProcedure; 
            SqlDataSource1.SelectParameters.Clear(); 
            SqlDataSource1.DataBind(); 
        } 

Does anyone have an idea as to what might be causing this?  It is happening on every single RadGrid in my application.  As I didn't have much data in the database through development, I never noticed the issue before.  Now that we are beginning to populate, it is becoming a problem.  Thank you for any help you can provide

1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 23 Sep 2009, 10:26 AM
Hello Daniel,

Simple data-binding through the DataBind() method can be used in simple scenarios which does not require complex operations like paging, sorting etc. For advanced features like paging, filtering. etc. Telerik RadGrid requires advanced data-binding through its NeedDataSource event or a data source control.

The correct approach when using simple data-binding is to call the DataBind() method on the first page load when !Page.IsPostBack and after handling some event (sort event for example). Keep in mind that if you choose simple data-binding, you will need to assign data-source and rebind the grid after each operation (paging, sorting, editing, etc.) - this copies exactly MS DataGrid behavior.

I hope this information helps.

Greetings,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Daniel Caves
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Share this question
or