RadGrid disappears after paging

2 posts, 0 answers
  1. Marc Plaxton-Harrison
    Marc Plaxton-Harrison avatar
    40 posts
    Member since:
    Mar 2008

    Posted 12 May 2018 Link to this post

    Good day Guys,

    I have two radgrids on the same page one works perfectly fine with paging and datasource bindings. 

    The second grid works with the filtering of raddatepickers. So a user has to filer certain data using the datepickers eg. from "date" to "date". Please note that the datepickers are not inside the grid but outside. i also have a button which is used as click event after the user selecting dates

    please see below code client side markup of the second grid which has a problem with the paging

    and also the code behind for filtering and and binding to the grid. Im using linq to Sql

    protected void btnfilter_Click(object sender, EventArgs e)
          {
            
              DateTime From = Convert.ToDateTime(RadDatePicker1.SelectedDate);
              DateTime To = Convert.ToDateTime(RadDatePicker2.SelectedDate);
     
              //rgApprovedTransactionsLists.MasterTableView.Rebind();
     
     
              var AprrovedTrans = (from s in db.OneTimePins
                                   join t in db.TransactionTypes on s.TransactionTypeID equals t.TransactionTypeID
                                   join userapp in db.Users on s.ApprovedBy equals userapp.UserID
                                   where (s.ApprovedDate >= From && s.ApprovedDate < To)
                                   select new
                                   {
                                       s.OneTimePinID,
                                       t.TransactionType1,
                                       s.PIN,
                                       s.Amount,
                                       s.WithdrawerID,
                                       s.WithdrawDate,
                                       s.ApprovedDate,
                                       s.CancellationDate,
                                       ApprovedBy = userapp.FirstName + " " + userapp.LastName
     
                                   });
     
              rgApprovedTransactionsLists.DataSource = AprrovedTrans.ToList();
              rgApprovedTransactionsLists.DataBind();
     
          }
    <div>
              <asp:Label ID="lblMessagefilter" runat="server" ></asp:Label>
          </div>
           <table>
              <tr>
                  <td align="center" style="width:50%;">
                    <telerik:RadLabel ID="RadLabel1" Text="From :" runat="server">
                      </telerik:RadLabel>
                  <telerik:RadDatePicker RenderMode="Lightweight" ID="RadDatePicker1"  DateInput-DateFormat="dd-MM-yyyy" runat="server">
                  </telerik:RadDatePicker>
                    
     
                  </td>
                  <td align="center" class="auto-style1">
                      <telerik:RadLabel ID="RadLabel2" Text="To :" runat="server">
                      </telerik:RadLabel>
                      <telerik:RadDatePicker RenderMode="Lightweight" ID="RadDatePicker2"  DateInput-DateFormat="dd-MM-yyyy" runat="server">
                  </telerik:RadDatePicker>
                     <telerik:RadButton ID="RadButton1" runat="server"  Text="filter" OnClick="btnfilter_Click" Width="100px">
                      </telerik:RadButton>
                  </td>
                                   
              </tr>
              </table>
     
     
         - <table width="700px">
              <tr>
                  <td>
                      <br />
                  </td>
              </tr>
             <tr>
                  <td>
                      <telerik:RadGrid ID="rgApprovedTransactionsLists" runat="server" AllowPaging="true" PagerStyle-AlwaysVisible="true" EnableViewState="true"
                          PageSize="10" AllowSorting="true"
                      OnPageIndexChanged="rgApprovedTransactionsLists_PageIndexChanged"
                      OnPageSizeChanged="rgApprovedTransactionsLists_PageSizeChanged"
                      OnNeedDataSource="rgApprovedTransactionsLists_NeedDataSource"
                      Width="1113px"
                      AutoGenerateColumns="False" >
     
                      <MasterTableView DataKeyNames="OneTimePinID" TableLayout ="Fixed" FilterItemStyle-BorderStyle="NotSet" MultiHeaderItemStyle-VerticalAlign="NotSet"  >
                              <Columns>
                                  <telerik:GridBoundColumn Visible="false" DataField="OneTimePinID" HeaderText="OneTimePinID" AllowSorting="true" >
                                      <HeaderStyle  Width="100px" HorizontalAlign="Center" Font-Bold="true"/>
                                      <ItemStyle HorizontalAlign="Center" />
                                  </telerik:GridBoundColumn>
     
                                   <telerik:GridBoundColumn DataField="TransactionType1" HeaderText="TransactionType" AllowSorting="true" >
                                      <HeaderStyle  Width="100px" HorizontalAlign="Center" Font-Bold="true"/>
                                      <ItemStyle HorizontalAlign="Center" />
                                  </telerik:GridBoundColumn>
     
                                  <telerik:GridBoundColumn DataField="PIN" HeaderText="One Time Pin"  AllowSorting="true">
                                      <HeaderStyle  Width="100px" HorizontalAlign="Center" Font-Bold="true"/>
                                      <ItemStyle HorizontalAlign="Center" />
                                  </telerik:GridBoundColumn>
                                  
                                  <telerik:GridBoundColumn DataField="Amount" HeaderText="Amount" >
                                       <HeaderStyle  Width="100px" HorizontalAlign="Center" Font-Bold="true"/>
                                       <ItemStyle HorizontalAlign="Center" />
                                  </telerik:GridBoundColumn>
     
                                  <telerik:GridBoundColumn DataField="WithdrawerID" HeaderText="WithdrawerID" AllowSorting="true">
                                       <HeaderStyle  Width="100px" HorizontalAlign="Center" Font-Bold="true"/>
                                       <ItemStyle HorizontalAlign="Center" />
                                  </telerik:GridBoundColumn>
     
                                  <telerik:GridBoundColumn DataField="WithdrawDate" HeaderText="Withdraw Date" AllowSorting="true">
                                      <HeaderStyle  Width="100px" HorizontalAlign="Center" Font-Bold="true"/>
                                      <ItemStyle HorizontalAlign="Center"/>
                                  </telerik:GridBoundColumn>
                                  <telerik:GridBoundColumn DataField="ApprovedDate" HeaderText="Approved Date" AllowSorting="true">
                                      <HeaderStyle  Width="100px" HorizontalAlign="Center" Font-Bold="true"/>
                                      <ItemStyle HorizontalAlign="Center"/>
                                  </telerik:GridBoundColumn>
     
                                     <telerik:GridBoundColumn DataField="CancellationDate" HeaderText="Cancellation Date" AllowSorting="true">
                                      <HeaderStyle  Width="100px" HorizontalAlign="Center" Font-Bold="true"/>
                                      <ItemStyle HorizontalAlign="Center"/>
                                  </telerik:GridBoundColumn>       
     
                                  <telerik:GridBoundColumn DataField="ApprovedBy" HeaderText="Approved By" AllowSorting="true">
                                      <HeaderStyle  Width="100px" HorizontalAlign="Center" Font-Bold="true"/>
                                      <ItemStyle HorizontalAlign="Center"/>
                                  </telerik:GridBoundColumn>                                                     
                                                              
                              </Columns>
                           </MasterTableView>
     
                      </telerik:RadGrid>
                  </td>
                  </tr>
                  </table>

     

     

    Help anyone will be appreciated 

    kind regards

    Marc

     

     

     

     

  2. Eyup
    Admin
    Eyup avatar
    3962 posts

    Posted 16 May 2018 Link to this post

    Hi Marc,

    Please make sure you are not using the DataBind() method to bind the grid:
    https://www.telerik.com/support/kb/aspnet-ajax/grid/details/how-to-bind-radgrid-properly-on-server-side

    As for applying default filtering, you can use the FireCommandEvent method. Here is a sample with Between function:
    https://www.telerik.com/forums/setting-a-filter-in-the-index-changed-event-of-a-drop-down-combo-not-filtering-the-grid#_QnXxSMs5Uq9rddb2JWcWA

    I hope this will prove helpful.

    Regards,
    Eyup
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top