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

Why Does my Paging and sorting not working correctl

0 Answers 8 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Perry
Top achievements
Rank 1
Perry asked on 15 Feb 2018, 03:44 PM

I have a radgrid with these propertie

AutoGenerateColumns="false"
               AllowAutomaticDeletes="true"
               AllowSorting="True"
               AllowPaging="true"
               AllowFilteringByColumn="true"
               OnInsertCommand="rgData_InsertCommand"
               OnUpdateCommand="rgData_UpdateCommand"
               OnItemDataBound="rgData_ItemDataBound"
               OnDeleteCommand="rgData_DeleteCommand"
               EnableViewState="true"
               OnItemCommand="rgData_ItemCommand"
               ShowStatusBar="true"
               OnInit="RgHomicideData_Init"
               OnNeedDataSource="rgData_NeedDataSource"
               CommandItemStyle-HorizontalAlign="Left">

 

The radgrid works as expected.  I use this code in my needdatasource

string strYear = DateTime.Now.Year.ToString();
            DateTime StartDate = Convert.ToDateTime("1/1/" + strYear);
            DateTime EndDate = Convert.ToDateTime("12/31/" + strYear);
            rgData.DataSource = DbContext.tblData
                .Where(d => d.deleted == false).ToList();

 

sort and paging is working properly

Now I want to filter the data by a date range so I use this code

Boolean DateChk1 = dpStartDate.SelectedDate.HasValue;
            Boolean DateChk2 = dpStartDate.SelectedDate.HasValue;
            string comboSearch = cboxSearch.Text;
            int intComboSearch = comboSearch.Length;
 
            if (comboSearch.Length > 0 && DateChk1 == true && DateChk2 == true)
            {
 
                DateTime Date1 = dpStartDate.SelectedDate.Value;
                DateTime Date2 = dpEndDate.SelectedDate.Value;
                rgData.DataSource = DbContext.AAADataSearchByDateRange(comboSearch, Date1, Date2).ToList();

The data refreshes and shows the filtered data.  Now if I click the column header to sort or I chnage to another page the radgrid looses all data and all I see is a line on the screen.  Can someone please explain the problem and how to fix it

 

Thanks

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Perry
Top achievements
Rank 1
Share this question
or