ListView Pagination Lost in Cross Page Postback

3 posts, 0 answers
  1. Meengla
    Meengla avatar
    2 posts
    Member since:
    Jan 2011

    Posted 31 Jan 2011 Link to this post

    I am post form data from, say, source.aspx to destination.aspx page. The source.aspx page has some checkboxes which are used in a SQL query in the destination.aspx page. For example,

     if (Request.Form["color_spice"] != null) { WhereClause += " OR ado_products_fabrics.color = 'spice'"; }

    The first time the destination page loads the RadListView shows the pagination fine. However, clicking on the RadDataPager under the RadListView causes a postback where the source.aspx page's Form data are lost. I have tried using PreviousPage.FindControl() method but that too does not resolve in the pagination's postback.

    So what can I do? I don't want to use Session variables--there are going to be dozens of controls from the source.aspx page passing values to destination.aspx page. Cookies too will be too much to track then?

    Below are the code-fragments for the .aspx and the .cs files.


    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
                <telerik:AjaxSetting AjaxControlID="RadListView1">
                        <telerik:AjaxUpdatedControl ControlID="ListViewPanel1" LoadingPanelID="RadAjaxLoadingPanel1" />
        <div style="width: 880">
         <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Black">
            <asp:Panel ID="ListViewPanel1" runat="server">
            <telerik:RadListView ID="RadListView1" runat="server" DataKeyNames="fabricid" AllowPaging="True">
                    <div class="RadListView RadListViewFloated RadListView_Default">
                        <div class="rlvFloated">
                            <div id="itemPlaceholder" runat="server">
                     <telerik:RadDataPager ID="RadDataPager1" runat="server" PagedControlID="RadListView1">
                    <telerik:RadDataPagerButtonField FieldType="Numeric"  />

    protected void Page_Load(object sender, EventArgs e)
           String WhereClause = string.Empty;
           //determine which button clicked
           if (Request.Form["btnTextGeneric"] != null)
               // do button 1 stuff
           else if (Request.Form["btnCBFabrics"] != null)
              if (Request.Form["color_spice"] != null) { WhereClause += " OR ado_products_fabrics.color = 'spice'"; }
    if (WhereClause != "")
               RadListView1.DataSource = GetDataTable("SELECT * FROM [ado_products_fabrics] WHERE 0 = 1" + WhereClause);
               RadListView1.DataSource = GetDataTable("SELECT * FROM [ado_products_fabrics]");

  2. Martin
    Martin avatar
    823 posts

    Posted 03 Feb 2011 Link to this post

    Hello Meengla,

    I am afraid that there is no other option than saving the where clause when the destination page is loaded for first time. The exact approach you will use to save the data (session, viewstate, cookie, etc.) does not affect the ListView control. However you will have to ensure that the correct data source is set to the ListView in any case that requires it to rebind (paging, sorting, etc).

    I hope this helps.

    Best wishes,
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  3. Meengla
    Meengla avatar
    2 posts
    Member since:
    Jan 2011

    Posted 03 Feb 2011 Link to this post

    Hi Martin,
    Thank you for your help. I was able to fix the problem by using Cookies. Works like a charm. If Cookies are not set then the 'Where' clause does not get stored and hence all records from the database are returned. Not ideal but then still better than Session based storage.
Back to Top