I have problem with my development task.
My ASPX File
and my Code file is
i used Telerik RadGrid and i need to show pagination using Stored Procedure where procedure returns only 50 records from database though there are 100K records in table.
Paging showing correctly.
using this code i get 50 records from database but does not appear in grid , i debug my code and its shows me in
can anybody guess why this happening
Thanks
My ASPX File
<
telerik:RadGrid
ID
=
"grd1"
runat
=
"server"
AllowFilteringByColumn
=
"True"
AllowPaging
=
"True"
AllowCustomPaging
=
"true"
AutoGenerateColumns
=
"False"
GridLines
=
"None"
OnItemDataBound
=
"grd1_OnItemDataBound"
OnItemCreated
=
"grd1_ItemCreated"
Width
=
"100%"
Skin
=
"Windows7"
ShowGroupPanel
=
"false"
CellSpacing
=
"0"
PageSize
=
"50"
OnNeedDataSource
=
"grd1_NeedDataSource"
OnPageIndexChanged
=
"grd1_PageIndexChanged"
OnPageSizeChanged
=
"grd1_PageSizeChanged"
>
and my Code file is
protected void grd1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
grd1.VirtualItemCount = 100000;
grd1.DataSource = GetDataSource();
grd1.DataBind();
}
private IEnumerable<
SearchClass
> Select(int pageSize, int pageIndex)
{
IQueryable<
SearchClass
> searchObj = DataClassLib.Search(pageSize, pageIndex).AsQueryable();
try
{
searchObj = searchObj .Select(x => new SearchClass
{
Id = x.Id,
Name = x.Name,
});
}
catch (Exception ex)
{
throw ex;
}
return searchObj;
}
private IEnumerable<
SearchClass
> GetDataSource()
{
int pageIndex = grd1.CurrentPageIndex;
int pageSize = grd1.PageSize;
if (pageIndex == 0)
pageIndex = 1;
IEnumerable<
SearchClass
> data = Select(pageSize,pageIndex);
return data == null ? new List<
SearchClass
>() : data.Skip(pageSize * pageIndex).Take(pageSize);
}
i used Telerik RadGrid and i need to show pagination using Stored Procedure where procedure returns only 50 records from database though there are 100K records in table.
Paging showing correctly.
using this code i get 50 records from database but does not appear in grid , i debug my code and its shows me in
GetDataSource()
that returns 50 records but when debug point comes to grd1.DataSource = GetDataSource();
this line in datasource it show me 0 count.can anybody guess why this happening
Thanks