I know that this question has been asked many times but I'm having problems getting paging working with my grid. I've looked at the examples and still can't get it right. Could someone please point me in the right direction with my code?
The grid loads the data successfully when the page is first loaded but if I try to page I first get a grid with all of the rows I would expect but no data. Then if I page again I get no grid just a blank page. What am I doing wrong? Note profileDal.SelectAll() creates a list of IProfile business objects by querying a SQL server database using a stored procedure. Calling profileDal.SelectAll() fetches all the data required first time. The data is not being fetched page by page.
<telerik:RadGrid ID="ProfileGrid" Width="100%" AllowFilteringByColumn="True" AllowSorting="True" PageSize="12" ShowFooter="True" AllowPaging="True" ViewStateMode="Enabled" runat="server" OnNeedDataSource="ProfileGrid_NeedDataSource" AutoGenerateColumns="false" GridLines="None" ShowStatusBar="true" AllowMultiRowSelection="True" DataKeyNames="ProfileID"> <GroupingSettings CaseSensitive="false" /> <MasterTableView> <Columns> <telerik:GridBoundColumn HeaderText="ProfileID" DataField="ProfileID" ReadOnly="True" UniqueName="ProfileID" Display="False" /> <telerik:GridClientSelectColumn UniqueName="CheckboxSelectColumn" /> <telerik:GridBoundColumn DataField="Email" HeaderText="Email" /> <telerik:GridBoundColumn DataField="FirstName" HeaderText="First Name" /> <telerik:GridBoundColumn DataField="LastName" HeaderText="Last Name" /> <telerik:GridBoundColumn DataField="Occupation" HeaderText="Occupation" /> <telerik:GridBoundColumn DataField="CompanyName" HeaderText="Company" /> <telerik:GridBoundColumn DataField="Source" HeaderText="Source" /> <telerik:GridBoundColumn DataField="ProfileLastModifiedDate" HeaderText="Modified" /> <telerik:GridButtonColumn Text="Delete" CommandName="Delete" /> <telerik:GridButtonColumn Text="View Full Profile" CommandName="View Full Profile" /> </Columns> </MasterTableView> <ClientSettings EnableRowHoverStyle="true"> <Selecting AllowRowSelect="True" /> </ClientSettings> </telerik:RadGrid>public partial class ProfilesGridControl : ProfileControlBase{ protected override void FillProfiles() { List<IProfile> profilesList = new List<IProfile>(); ProfileDal profileDal = new ProfileDal(); profilesList = profileDal.SelectAll(); ViewState["Profiles"] = profilesList; ProfileGrid.DataSource = ViewState["Profiles"]; } protected void ProfileGrid_NeedDataSource(object source, GridNeedDataSourceEventArgs e) { if (ViewState["Profiles"] != null) { ProfileGrid.DataSource = ViewState["Profiles"]; } { FillProfiles(); } }}The grid loads the data successfully when the page is first loaded but if I try to page I first get a grid with all of the rows I would expect but no data. Then if I page again I get no grid just a blank page. What am I doing wrong? Note profileDal.SelectAll() creates a list of IProfile business objects by querying a SQL server database using a stored procedure. Calling profileDal.SelectAll() fetches all the data required first time. The data is not being fetched page by page.