Hi everyone
Im trying to load data in RadGrid, everything is right except no paging,
I click on page number to change the page but no paging occurs or no data is rendered
I use GetDataAndCount event to load the data, the output type of the method is ResultData (this class contains a generic list and counter)
I think Im missing something, can you help me.
I provide some code:
<telerik:RadGrid ID="GvProfiles" runat="server" AllowPaging="true" AllowCustomPaging="false"
AllowSorting="true" AllowFilteringByColumn="true" FilterType="CheckList" ShowFooter="true">
<MasterTableView AutoGenerateColumns="false" DataKeyNames="ProfileID" ClientDataKeyNames="ProfileID" CheckListWebServicePath="ProfilesService.svc">
<PagerStyle Mode="NumericPages"></PagerStyle>
<Columns>
<telerik:GridBoundColumn FilterDelay="200" FilterCheckListWebServiceMethod="GetProfileNames"
DataField="ProfileName" HeaderText="Profile Name" UniqueName="ProfileID" DataType="System.String">
</telerik:GridBoundColumn>
</Columns>
<PagerStyle AlwaysVisible="true"></PagerStyle>
</MasterTableView>
<ClientSettings>
<ClientEvents OnDataBound="OnDataBound" OnGridCreated="OnGridCreated" />
<DataBinding SelectMethod="GetDataAndCount" Location="ProfilesService.svc"
SortParameterType="String" FilterParameterType="String">
</DataBinding>
</ClientSettings>
<FilterMenu CssClass="RadFilterMenu_CheckList">
</FilterMenu>
</telerik:RadGrid>
[DataContract]
public class Profiles
{
[DataMember]
public Int64 ProfileID { get; set; }
[DataMember]
public String ProfileName { get; set; }
}
public class ResultData
{
public int Count { get; set; }
public List<Profiles> Data { get; set; }
}
[ServiceKnownType(typeof(Profiles))]
[ServiceContract]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class ProfilesService
{
[OperationContract]
public RadListBoxItemData[] GetProfileNames(Dictionary<string, object> context)
{
BusinessLayer.ProfilesBL objProfilesBL = new BusinessLayer.ProfilesBL();
List<DataLayer.Profiles> listProfiles = new List<DataLayer.Profiles>();
List<Profiles> listWcfProfiles = new List<Profiles>();
try
{
listProfiles = objProfilesBL.Select(new DataLayer.Profiles());
listProfiles.ForEach(delegate(DataLayer.Profiles item)
{
listWcfProfiles.Add(new Profiles { ProfileID = item.ProfileID, ProfileName = item.ProfileName });
});
return listWcfProfiles.Select(o => new RadListBoxItemData { Text = o.ProfileName, Value = o.ProfileID.ToString() }).ToArray<RadListBoxItemData>();
}
catch (Exception ex)
{
throw ex;
}
finally
{
objProfilesBL = null;
listProfiles = null;
listWcfProfiles = null;
}
}
[OperationContract]
public ResultData GetDataAndCount(int startRowIndex, int maximumRows, string sortExpression, string filterExpression)
{
BusinessLayer.ProfilesBL objProfilesBL = new BusinessLayer.ProfilesBL();
List<DataLayer.Profiles> listProfiles = new List<DataLayer.Profiles>();
IQueryable iQueryable;
GridLinqBindingData gridLinqBindingData;
ResultData resultData = new ResultData();
List<Profiles> listProfilesService = new List<Profiles>();
try
{
listProfiles = objProfilesBL.Select(new DataLayer.Profiles());
iQueryable = listProfiles.AsQueryable();
gridLinqBindingData = RadGrid.GetBindingData(iQueryable, startRowIndex, maximumRows, string.Empty, string.Empty);
if (string.IsNullOrEmpty(sortExpression))
sortExpression = "ProfileName ASC";
if (!string.IsNullOrEmpty(filterExpression))
{
filterExpression = filterExpression.Replace("[", string.Empty);
filterExpression = filterExpression.Replace("]", string.Empty);
filterExpression = filterExpression.Replace("'", "\"");
}
else
filterExpression = "ProfileID > 0";
resultData.Data = gridLinqBindingData.Data.OfType<DataLayer.Profiles>().Select(o => new Profiles()
{
ProfileID = o.ProfileID,
ProfileName = o.ProfileName
}).Where(filterExpression).OrderBy(sortExpression).ToList();
resultData.Count = listProfiles.Count;
return resultData;
}
catch (Exception ex)
{
throw ex;
}
finally
{
objProfilesBL = null;
listProfiles = null;
iQueryable = null;
gridLinqBindingData = null;
resultData = null;
}
}



| <%@ Master Language="C#" AutoEventWireup="true" CodeFile="SingleCenterColumn.master.cs" |
| Inherits="App_Master_SingleCenterColumn" %> |
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <html xmlns="http://www.w3.org/1999/xhtml"> |
| <head runat="server"> |
| <title></title> |
| </head> |
| <body> |
| <div id="wrapper"> |
| <form id="form2" runat="server"> |
| <telerik:RadScriptManager ID="RadScriptManager1" runat="server"> |
| </telerik:RadScriptManager> |
| <telerik:RadAjaxManager ID="AjaxManager1" runat="server"> |
| </telerik:RadAjaxManager> |
| <div id="centerwrapper"> |
| <div id="header" class="borders"> ... |
| <%@ Control Language="C#" AutoEventWireup="true" CodeFile="NeedsSurvey.ascx.cs" Inherits="NeedsSurvey_NeedsSurvey" |
| ClassName="NeedSurvey" %> |
| <telerik:RadAjaxManagerProxy ID="AjaxManagerProxy1" runat="server"> |
| <AjaxSettings> |
| <telerik:AjaxSetting AjaxControlID="Button1"> |
| <UpdatedControls> |
| <telerik:AjaxUpdatedControl ControlID="percentage" /> |
| <telerik:AjaxUpdatedControl ControlID="number" /> |
| <telerik:AjaxUpdatedControl ControlID="panel1" /> |
| <telerik:AjaxUpdatedControl ControlID="panel2" /> |
| </UpdatedControls> |
| </telerik:AjaxSetting> |
| <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server"> |
| </telerik:RadAjaxLoadingPanel> |
| <h1> |
| Needs Assessment Survey</h1> |
| <div id="slider"> |
| <asp:Label ID="percentage" runat="server" Text="0"></asp:Label>% Complete. Question |
| <asp:Label ID="number" runat="server" Text="0"></asp:Label> of 12 Completed. |
| <telerik:RadSlider ID="RadSlider1" runat="server"> |
| </telerik:RadSlider> |
| </div> |
| <asp:Panel runat="server" ID="panel1"> |
| 1. Which of the following best describes the personal needs you feel are the most |
| immediate? |
| <br /> |
| <br /> |
| <asp:RadioButtonList ID="RadioButtonList1" runat="server"> |
| <asp:ListItem>Help with everday expenses</asp:ListItem> |
| <asp:ListItem>Paying off debt</asp:ListItem> |
| <asp:ListItem>Taking a vacation</asp:ListItem> |
| <asp:ListItem>Home improvements</asp:ListItem> |
| <asp:ListItem>Better medical coverage</asp:ListItem> |
| </asp:RadioButtonList> |
| <br /> |
| <asp:Button ID="Button1" runat="server" OnClick="btn_Click1" /> |
| <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="RadioButtonList2" |
| ErrorMessage="Please select an answer"></asp:RequiredFieldValidator> |
| </asp:Panel>... |
| using System; |
| using System.Collections.Generic; |
| using System.Linq; |
| using System.Web; |
| using System.Web.UI; |
| using System.Web.UI.WebControls; |
| using System.Net.Mail; |
| using System.Net.Mime; |
| using System.Reflection; |
| using System.Collections.Specialized; |
| public partial class NeedsSurvey_NeedsSurvey : System.Web.UI.UserControl |
| { |
| protected void Page_Load(object sender, EventArgs e) |
| { |
| } |
| #region EventHandlers |
| protected void btn_Click1(object sender, EventArgs e) |
| { |
| panel1.Visible = false; |
| panel2.Visible = true; |
| RadSlider1.Value = 1; |
| percentage.Text = "8"; |
| number.Text = "1"; |
| } |
| protected void btn_Click2(object sender, EventArgs e) |
| { |
| panel2.Visible = false; |
| panel3.Visible = true; |
| RadSlider1.Value = 2; |
| percentage.Text = "16"; |
| number.Text = "2"; |
| }... |
| #centercolumn |
| { |
| width: 900px; |
| margin-top: 25px; |
| margin-left: auto; |
| margin-right: auto; |
| padding: 10px 25px 25px 25px; |
| background-color: #fff; |
| color: #000; |
| } |
| #slider |
| { |
| width: 300px; |
| margin: 0 auto; |
| } |