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

In custome paging Next ,Previous ,Fisrt, Last Paging button not working

6 Answers 380 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kiresh
Top achievements
Rank 1
Kiresh asked on 06 Apr 2013, 01:09 PM
When i click on fist second Page index it works good but when  i click on Next,Previous and last Fist Page Index Button it does not working.
 
here is my aspx page
<telerik:RadGrid ID="grdReferralSearch" runat="server" AllowFilteringByColumn="True"
              AllowPaging="True" AllowCustomPaging="true" AutoGenerateColumns="False" GridLines="None"
              OnItemDataBound="grdReferralSearch_OnItemDataBound" OnItemCreated="grdReferralSearch_ItemCreated"
              Width="100%" Skin="Windows7" ShowGroupPanel="false" CellSpacing="0" PageSize="50"
              OnPageIndexChanged="grdReferralSearch_PageIndexChanged" OnPageSizeChanged="grdReferralSearch_PageSizeChanged">
              <GroupingSettings ShowUnGroupButton="true" CaseSensitive="false" />
              <MasterTableView DataKeyNames="Id" AllowFilteringByColumn="True" ShowHeader="true"
                AllowMultiColumnSorting="false" >
                <ItemStyle BorderStyle="Solid" />
                <SortExpressions>
                  <telerik:GridSortExpression FieldName="ReferralName" SortOrder="Ascending" />
                </SortExpressions>
                <HeaderStyle Font-Bold="true" />
                <Columns>
                  <telerik:GridBoundColumn DataField="ReferralName" HeaderText="Referral Name" SortExpression="ReferralName"
                    FilterControlWidth="100" ItemStyle-Width="100" />
                  
                </Columns>
                <PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="True" Position="Top" HorizontalAlign="Right" />
              </MasterTableView>
              <FilterMenu EnableImageSprites="False">
              </FilterMenu>
            </telerik:RadGrid>

and here is my code
protected void Page_Load(object sender, EventArgs e)
    {
      try
      {
       if (IsPostBack == false)
        {
          BindReferralLookUp();
        }
        if (Page.IsCallback == false)
        {
          BindReferralLookUp();
        }
      }
      catch (Exception ex)
      {
        ShowError(ex.Message);
      }
 
protected void grdReferralSearch_PageIndexChanged(object sender, GridPageChangedEventArgs e)
    {
      try
      {
        grdReferralSearch.CurrentPageIndex = e.NewPageIndex;
        BindReferralLookUp();
      }
      catch (Exception ex)
      {
        ShowError(ex.Message);
      }
    }
 
 private void BindReferralLookUp()
    {
      try
      {
        grdReferralSearch.VirtualItemCount = 10000;
        grdReferralSearch.DataSource = GetDataSource();
        grdReferralSearch.DataBind();
      }
      catch (Exception ex)
      {
        throw ex;
      }
 
private List<ReferralSearchLookUp> GetDataSource()
    {
      try
      {
        lblTotalFound.Text = string.Empty;
        string referralName = string.Empty;
 
        if (!string.IsNullOrEmpty(txtReferralName.Text.Trim()))
        {
          referralName = txtReferralName.Text.Trim();
        }
 
        int pageIndex = grdReferralSearch.CurrentPageIndex + 1;
        int pageSize = grdReferralSearch.PageSize;
        int startIndex = (pageIndex - 1) * pageSize + 1;
        int endIndex = (pageIndex * pageSize);
 
        var data = ReferralsData.ReferralSearch(referralName, startIndex, endIndex);
 
        return data;
      }
      catch (Exception ex)
      {
        throw ex;
      }
    }

Can anybody help me?

Thanks,

6 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 07 Apr 2013, 01:54 PM
Hello,

Please check below link.
http://www.telerik.com/help/aspnet-ajax/grid-pageritem.html

You can add and use any command buttons to control grid paging. When using command buttons to control paging, set the CommandName to "Page", and the CommandArgument to "Next", "Prev", or the number of a page (e.g. "5").

Note : you have to access those button and you have to assign CommanName as "Page" and set based on current page index you have to set CommandArgument.

Thanks,
Jayesh Goyani
0
Kiresh
Top achievements
Rank 1
answered on 08 Apr 2013, 04:10 AM
Hey Jayesh,

I appreciate with your link but it would be nice if send me any sample code.

Thanks,
0
Shinu
Top achievements
Rank 2
answered on 08 Apr 2013, 04:41 AM
Hi,

Please try removing AllowCustomPaging property. Also make sure that grid uses advanced data binding using its NeedDataSource event.

Thanks,
Shinu
0
Kiresh
Top achievements
Rank 1
answered on 08 Apr 2013, 05:14 AM
Hey Shinu,
I do not want to use NeedDataSource event.

i just want to use Custom paging only. and its working as per Jayesh Goyani told to set
if (e.Item is GridPagerItem)
{        
          e.Item.OwnerTableView.PagerStyle.FirstPageText = "First";
          e.Item.OwnerTableView.PagerStyle.PrevPageText = "Prev";
          e.Item.OwnerTableView.PagerStyle.NextPageText = "Next";
          e.Item.OwnerTableView.PagerStyle.LastPageText = "Last";
}

and its showing both custom button and by-defaults button as shown in image.
can you help me to come-out this situation ?

Thanks
0
shruti
Top achievements
Rank 1
answered on 20 Jun 2015, 05:44 PM

I am using Pagination in radgrid. On first time page load the pager buttons are visible but when i click on next arrow button or a number index in the pager, the pager buttons are not visible even though grid is populating with correct data. What can be the reason. Any input will be appreciated.

Thanks

0
Eyup
Telerik team
answered on 25 Jun 2015, 06:18 AM
Hello Shruti,

Could you verify that you are not using DataBind() to bind the grid? Performing complex grid operations such as Inserting, Deleting, Updating, Hierarchy relations, Grouping, Exporting, Paging, Sorting, Filtering, etc. require accommodating appropriate database operations.  Therefore, we suggest you to avoid Simple Databinding and strongly recommend the use of more advanced databinding methods, which automatically handle the aforementioned functions:
Declarative DataSource
Programmatic Data Binding


If this is not the case, you can temporarily disable any AJAX on the page if present (RadAjaxManager, RadAjaxPanel, UpdatePanel, etc.) and enable your script debugger (FireBug or F12) to see whether there is script error interfering.


Regards,
Eyup
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Kiresh
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Kiresh
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
shruti
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or