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

Problems with pagin

8 Answers 179 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Woutersl
Top achievements
Rank 1
Woutersl asked on 25 Jun 2008, 09:43 AM
Hy,

I'm currently working on a webproject for one of our clients and I'm experiencing a strange problem with paging on the RadGrid. Hope someone will be able to help me.

I'm using a RadGrid to show some DB related data wich I have put into a DataTable before filling the RadGrid. When I fill the RadGrid I see the exact amount of rows and I see a certain number of pages at the bottom of my grid. When I click on the next page arrow, I can actually go to the page 2, so far so good. But when I click the next page again (to go to page 3 in this case), nothing happens.
I can navigate between page 1 and 2 without a problem, but I can't get any further.

For your Info I downloaded and installed the latest release and modified my Web.config to use the latest version.

You can find my code below. Fyi, this is the code of the usercontrol that contains the RadGrid. I have no Scriptmanager on the control, since I need to be able to add multiple custom controls to one page, so I added the Scriptmanager to the page. So I do infact have a Scriptmanager present.

Control
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ARTravelList.ascx.cs" Inherits="Website.Controls.ARTravelList" %>

<telerik:RadAjaxManager ID="ajaxManager" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="grdTravels">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="grdTravels" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>

<div id="pageColorHeader">
    <div class="colorHeaderText">REISOVERZICHT GROEPEN</div>
    <div id="colorHeaderSub">NIEUW</div>
</div>

<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server">

<telerik:RadGrid ID="grdTravels" runat="server" OnItemDataBound="grdTravel_ItemDataBound" OnItemCommand="grdTravel_ItemCommand" AutoGenerateColumns="false" AllowAutomaticDeletes="false" AllowAutomaticInserts="false" AllowAutomaticUpdates="false" AllowMultiRowEdit ="false" AllowMultiRowSelection="false" Skin="Hay" AllowPaging="true" AllowSorting="true" OnNeedDataSource="grdTravel_NeedDataSource" PageSize="50">


<MasterTableView DataKeyNames="Id" NoMasterRecordsText="Er zijn geen reizen gevonden van dit type">
       
        <ExpandCollapseColumn Visible="False">
            <HeaderStyle Width="19px"></HeaderStyle>
        </ExpandCollapseColumn>
        <RowIndicatorColumn Visible="False" >
            <HeaderStyle Width="20px"></HeaderStyle>
        </RowIndicatorColumn>
        <Columns>
            <telerik:GridBoundColumn Visible="False" ReadOnly="True" UniqueName="Id" DataField="Id">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn HeaderText="Bestemming" UniqueName="Destination" DataField="Destination">
            </telerik:GridBoundColumn>
            <%-- <telerik:GridBoundColumn HeaderText="Beschrijving" UniqueName="Description" DataField="Description">
            </telerik:GridBoundColumn> --%>
            <telerik:GridTemplateColumn HeaderText="Beschrijving" UniqueName="Description">
                <ItemTemplate>
                    <asp:HyperLink ID="lnkDescription" runat="server" />
                </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridBoundColumn HeaderText="Heen" UniqueName="DepartureDate" DataType=System.DateTime DataFormatString="{0:dd/MM/yy}" DataField="DepartureDate">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn HeaderText="Terug" UniqueName="ReturnDate" DataType=System.DateTime DataFormatString="{0:dd/MM/yy}" DataField="ReturnDate">
            </telerik:GridBoundColumn>
            <telerik:GridTemplateColumn HeaderText="Niveau" UniqueName="NiveauIMG" DataField="Niveau.Grade">
                <ItemTemplate>
                    <asp:Image ID="imgNiveau" runat="server" AlternateText="stapper" />
                </ItemTemplate>
            </telerik:GridTemplateColumn>
       </Columns>
     
      
</MasterTableView>

<PagerStyle PagerTextFormat="{4}    Huidige pagina {0} van {1}, items {2} tot {3} van {5}"/> 

<ClientSettings EnableRowHoverStyle="true" EnablePostBackOnRowClick="true">
 
</ClientSettings>

</telerik:RadGrid>

</telerik:RadAjaxPanel>

Code Behind
public partial class ARTravelList : ControlBase
    {
        private string _TravelType;
        public string TravelType
        {
            get { return _TravelType; }
            set { _TravelType = value; }
        }       
        public string PreviousTravelType
        {
            get { return (Session["TravelType"] == null) ? null : (string)Session["TravelType"]; }
            set { Session["TravelType"] = value; }
        }
       
      
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                PreviousTravelType = Request.QueryString["ReisType"].ToString();
               
            }         
        }

        protected void grdTravel_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            grdTravels.DataSource =GetAllTravels() ;
        }

        protected void grdTravel_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                DataRowView dvTravel = e.Item.DataItem as DataRowView;

                HyperLink lnkDescription = e.Item.FindControl("lnkDescription") as HyperLink;
                if (lnkDescription == null) return;
                if (lnkDescription != null)
                {
                    lnkDescription.NavigateUrl = "~/nl/ReisDetail/" + _TravelType + "/" + dvTravel["TravelId"] + ".aspx";// "mailto:" + dvInsurance["Email"].ToString();
                    lnkDescription.Text = dvTravel["Description"].ToString();
                }
                Image imgNiveau = e.Item.FindControl("imgNiveau") as Image;
                if (imgNiveau == null) return;
                if (imgNiveau != null)
                {
                    imgNiveau.ImageUrl = dvTravel["Niveau"].ToString();                   
                }
            }
        }

        protected void grdTravel_ItemCommand(object source, GridCommandEventArgs e)
        {
            if (e.CommandName == "RowClick" && e.Item is GridDataItem)
            {
                string url = string.Empty;
                DataRowView oRow = (DataRowView)e.Item.DataItem;
                string TravelId = oRow["TravelId"].ToString();

                if (TravelType == "Default")
                    TravelType = PreviousTravelType;

                url = UrlHelper.Instance.GetSiteUrl() + "/nl/ReisDetail/" +
                   TravelType + "/" + TravelId + ".aspx";

                Response.Redirect(url);               
            }
        }

        private DataTable GetAllTravels()
        {
            return CreateDataTableFromList(GetTravel());
        }

        private DataTable CreateDataTableFromList(List<ARTravel> List)
        {
            DataTable oTable = new DataTable();
            oTable.Columns.Add("Id", typeof(Int32));
            oTable.Columns.Add("TravelId");
            oTable.Columns.Add("Destination");
            oTable.Columns.Add("Description");
            oTable.Columns.Add("DepartureDate");
            oTable.Columns.Add("ReturnDate");
            oTable.Columns.Add("Niveau");           

            foreach (ARTravel oItem in List)
            {
                DataRow oRow = oTable.NewRow();
                oRow["Id"] = oItem.Id;
                oRow["TravelId"] = oItem.TravelId;
                oRow["Destination"] = oItem.Destination.Name;
                oRow["Description"] = oItem.Description;

                oRow["DepartureDate"] = oItem.DepartureDate.ToShortDateString();
                oRow["ReturnDate"] = oItem.ReturnDate.ToShortDateString();

                oRow["Niveau"] = UrlHelper.Instance.GetSiteUrl() + "/img/ventjes" + oItem.Niveau.Grade + ".gif";
                               
                oTable.Rows.Add(oRow);
            }           

            return oTable;
        }

        private List<ARTravel> GetTravel()
        {
            TravelType = Request.QueryString["ReisType"];
            if (TravelType == "Default")
                TravelType = PreviousTravelType;
            ARTravel graph = new ARTravel(new ARNiveau(), new ARType(TravelType),new ARDestination());
            List<ARTravel> reizen = TravelFacade.Instance.GetTravels(true,TravelType, graph);

            return reizen;
        }              
    }

8 Answers, 1 is accepted

Sort by
0
Konstantin Petkov
Telerik team
answered on 27 Jun 2008, 11:34 AM
Hello Woutersl,

Were you able to resolve the problem? I just found you've closed your ticket.

If you still need our assistance, please use the same ticket to send a sample which replicates the problem (along with the database if needed or a dummy one just to simulate the problem). I'm out of ideas for the time being what might be causing the problem so we will definitely need your code to debug locally.

All the best,
Konstantin Petkov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Marc
Top achievements
Rank 1
answered on 24 Nov 2008, 11:36 AM
I had the same problem with a grid bound to a datatable.  Clicking the numeric pages worked okay but using the next arrow would not progress beyond page 2.  The only resolution I could find was to disable the viewstate for the grid.

I had a RadAjaxManager in the masterpage, so I'm guessing that the viewstate value holding the current page was not being updated in an ajax postback or something along those lines.

Not missing the viewstate features at the moment but would be good to know if there is a resolution?

Here's the code that had the problem before disabling the viewstate:

<telerik:RadGrid ID="ResultsRadGrid" runat="server" GridLines="None" OnNeedDataSource="ResultsRadGrid_NeedDataSource" AllowPaging="True" PageSize="15" ShowGroupPanel="True" Skin="WebBlue"> 
 <PagerStyle Mode="NextPrevAndNumeric" Position="TopAndBottom" AlwaysVisible="true" HorizontalAlign="Center" PageButtonCount="30" />
 <MasterTableView AllowNaturalSort="False" ShowFooter="True"> 
 <RowIndicatorColumn> 
  <HeaderStyle Width="20px" /> 
 </RowIndicatorColumn> 
 <ExpandCollapseColumn> 
  <HeaderStyle Width="20px" /> 
 </ExpandCollapseColumn> 
</MasterTableView> 

<ClientSettings AllowDragToGroup="True"> </ClientSettings>
<FilterMenu EnableTheming="True"> 
<CollapseAnimation Duration="200" Type="OutQuint" /> 
</FilterMenu> 
</telerik:RadGrid>

protected void ResultsRadGrid_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
    ResultsRadGrid.AutoGenerateColumns = true;  
    ResultsRadGrid.DataSource = this.ResultsDataTable;
}

0
Vlad
Telerik team
answered on 27 Nov 2008, 07:18 AM
Hello Marc,

Can you verify if you have our latest service pack?

Kind regards,
Vlad
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
ADe
Top achievements
Rank 1
answered on 11 Feb 2009, 10:59 AM
I get this exact problem and am using version Q3 2008 1314. The ViewState suggestion above has worked also although when I do this it does not highlight the page that i'm currently on.

Has anyone found a reso0lution for this?
0
Sebastian
Telerik team
answered on 11 Feb 2009, 11:24 AM
Hello ADe,

The answers to the following questions can help us determine the exact source of the issue to address it accordingly:

  1. What type of binding you use for your grid - server-side binding with NeedDataSource handling, data source control, client-side binding?
  2. Do you receive any errors when attempting to advance by clicking the Next/Prev images in the pager?
  3. Does using Next/Prev type pager or NextPreviousNumericAndAdvanced produces the same result?
  4. Does migrating to the latest internal build make a difference?
Best regards,
Sebastian
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
ADe
Top achievements
Rank 1
answered on 11 Feb 2009, 01:47 PM

1.   What type of binding you use for your grid - server-side binding with NeedDataSource handling, data source control, client-side binding?

Server side I am assigning a DataTable as the DataSource and calling the DataBind method like so,

RadGrid1.DataSource = myDataSet.Tables[myTable];

RadGrid1.DataBind();

 

 

2.   Do you receive any errors when attempting to advance by clicking the Next/Prev images in the pager?

Both the images and the links cause the issue but no actual errors are reported.

3.   Does using Next/Prev type pager or NextPreviousNumericAndAdvanced produces the same result?

Yep all have the same result.

4.   Does migrating to the latest internal build make a difference?

Just tried that. Same problem.

0
Sebastian
Telerik team
answered on 11 Feb 2009, 01:59 PM
Hello ADe,

Thank you for the answers. I suggest you switch to advanced binding with NeedDataSource event handling to see whether this helps. Note that advanced pagers are not supported with simple binding with DataBind() calls and for simple pagers you will need to intercept the PageIndexChanged event of the grid and switch the page index manually as you will do that with standard MS GridView control.

Best,
Sebastian
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Woutersl
Top achievements
Rank 1
answered on 17 Mar 2009, 02:34 PM
Hy,

Sorry for this late reply, as I was cleaning out my watched topics I noticed that I didn't mark this post as resolved, nor did I mention what did solve this problem for me.

In the support ticket I created for this issue we came to the conclussion that the RadAjaxPanel was causing the problem. Although we are not sure why. Replacing it by a regular asp UpdatePanel solved the issue for us.

However I haven't encountered the problem in later versions of the controls.
Tags
Grid
Asked by
Woutersl
Top achievements
Rank 1
Answers by
Konstantin Petkov
Telerik team
Marc
Top achievements
Rank 1
Vlad
Telerik team
ADe
Top achievements
Rank 1
Sebastian
Telerik team
Woutersl
Top achievements
Rank 1
Share this question
or