Why Does my Paging and sorting not working correctl

1 posts, 0 answers
  1. Perry
    Perry avatar
    62 posts
    Member since:
    Jul 2015

    Posted 15 Feb 2018 Link to this post

    I have a radgrid with these propertie



    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



Back to Top