I have used custom paging using NeedDataSource but i see a very strange behavior of my RadGrid. I have about 800 records and i am displaying 10 records per page. Also, there is a search mechanism at the top using that user can search records ( i am not using internal filters). Everything works fine. I am taking my search parameters in my radgvRecords_NeedDataSource function and its being passed properly with RowIndexNum and MaximumRows parameters which handles paging.
I see first 10 records on page 1. When i click page 2, i just see 1 record. I checked my stored proc. It is returning 11 records when i pass RowIndexNum =10 and MaximumRows =10. So data is coming perfectly from database but RadGrid only displays the last row from this result set. I see data going through my BAL to my ASPX.CS page. The other strange part is when i hit page 3,4,5,6,7,... i see data properly without any problem. Its just on page 2. I am pasting my bidding code here.
I see first 10 records on page 1. When i click page 2, i just see 1 record. I checked my stored proc. It is returning 11 records when i pass RowIndexNum =10 and MaximumRows =10. So data is coming perfectly from database but RadGrid only displays the last row from this result set. I see data going through my BAL to my ASPX.CS page. The other strange part is when i hit page 3,4,5,6,7,... i see data properly without any problem. Its just on page 2. I am pasting my bidding code here.
protected
void
radgvRecords_NeedDataSource(
object
sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
// get search paramters
string
fname = txtPatientFName.Text.Trim();
string
lname = txtPatientLName.Text.Trim();
string
sDate = txtStartDate.Text.Trim();
string
eDate = txtEndDate.Text.Trim();
string
email = txtEmail.Text.Trim();
int
docid = Int32.Parse(ddlDoctors.SelectedValue.ToString());
int
clinicId = Int32.Parse(Session[
"cid"
].ToString());
bool
status =
false
;
// balance search parameters
if
(sDate.Trim() ==
null
|| sDate.Equals(
""
))
{
sDate = System.Data.SqlTypes.SqlDateTime.MinValue.Value.ToShortDateString();
}
if
(eDate.Trim() ==
null
|| eDate.Equals(
""
))
{
eDate = DateTime.Now.ToShortDateString();
}
objFactory fac =
new
objFactory();
IPrescription objPres = fac.getPrescriptionObject();
VirtualItemCount = objPres.getTotalCountForSearchResult(sDate, eDate, fname, lname, docid, email, clinicId);
radgvRecords.MasterTableView.VirtualItemCount = VirtualItemCount;
radgvRecords.VirtualItemCount = VirtualItemCount ;
int
startRowIndex = ((ShouldApplySortFilterOrGroup())? 0 : radgvRecords.CurrentPageIndex * radgvRecords.PageSize);
int
maximumRows = ((ShouldApplySortFilterOrGroup())? VirtualItemCount: radgvRecords.PageSize) ;
List<IPrescription> pList = objPres.searchPrescriptionCustomPaging(sDate, eDate, fname, lname, docid, email, clinicId, startRowIndex, maximumRows);
radgvRecords.DataSource = pList;
}