Radlistview and data caching

2 posts, 0 answers
  1. Fabio Cirillo
    Fabio Cirillo avatar
    179 posts
    Member since:
    Jan 2010

    Posted 08 Mar 2013 Link to this post

    I'm using a radlistview with raddatapager to view the selected records in a database after a search. Now so that when you click on raddatapager to see the records in the listview, it should retry the connection to the database and re-run the query select sql, I thought of using the data caching using the method OutputCache. Obviously use the OutputCache only if they do not change the search parameters. But now I have a problem that I set the radlistview to 10 records per page, load 25 records, I have 3 pages to be displayed, using the OutputCache when licco DataPager on arrival to the second page and then stops do not go forward. I thought of setting the html code on the page this parameter: <% @ OutputCache duration = "300" VaryByParam = "_str1, _str2, RadDataPager1"%>, but nothing does not work. send time is the html code of the page, and the code vb net.

    html code:
    <%@ Page Language="vb" AutoEventWireup="false" CodeFile="search.aspx.vb" Inherits="search" %>
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <%@ OutputCache duration="600" VaryByParam="_str1,_str2,RadListView1" %>
    <%@ Import Namespace="TRYcontact" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head runat="server">
    <meta name="description" content="Trycontact; il social network che ti collega alla community con il tuo biglietto da visita virtuale." />
    <link href="App_Themes/TryCss/chrome.css" rel="stylesheet" type="text/css" />
    <title>TRYcontact: risultati della ricerca</title>
    <script type="text/javascript">
    // prendo valore div contenitore radlistview
    function Height_Div() {
    var _heightdiv1 = document.getElementById("div_radlistview").offsetHeight;
    var _positiondiv2 = document.getElementById("under");
    //_positiondiv2.style.top = (_heightdiv1) + "px";
    function DoPostBack() {
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    <telerik:AjaxSetting AjaxControlID="ImageButtonRicerca">
    <telerik:AjaxUpdatedControl ControlID="Panel1"
    LoadingPanelID="RadAjaxLoadingPanel1" />
    <telerik:AjaxSetting AjaxControlID="RadListView1">
    <telerik:AjaxUpdatedControl ControlID="RadWindowCard"
    LoadingPanelID="RadAjaxLoadingPanel1" />
    <telerik:RadNotification ID="RadNotification1" runat="server" Height="100px"
    Skin="Simple" TitleIcon="~/Image/iconlogo.png" Width="400px"
    AutoCloseDelay="3500" Position="Center" Title="Notifica trycontact">
    <asp:HiddenField ID="_search" runat="server" /><asp:HiddenField ID="_search1" runat="server" />
    <telerik:RadFormDecorator ID="RadFormDecorator" Runat="server"
    DecoratedControls="Default, Textbox, Textarea, Label, H4H5H6, Select, Zone, GridFormDetailsViews, ValidationSummary, LoginControls"
    Skin="Sunset" />
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" Runat="server"
    BorderColor="#D5842B" BorderStyle="Double" BorderWidth="1px" Skin="Simple">
    <div align="center" class="backgroundup">
    <div align="center" class="banner">
    <div style="padding-left:200px;">
    <div class="profilesearch">
    <asp:Panel ID="Panel1" runat="server" DefaultButton="ImageButtonRicerca" Height="55px" Width="685">
    <div id="txt1" style="width:350px; height:22px; border:0px; margin:0px; padding-top:15px; padding-right:1px; float:left">
    <telerik:RadTextBox ID="Txt_ricerca1" Runat="server"
    EmptyMessage="Nominativo o azienda o categoria" Width="350px" Height="22px" Skin="" Font-Italic="True"
    <EmptyMessageStyle ForeColor="Gray" Font-Italic="True" Font-Names="Verdana" />
    <HoveredStyle Font-Italic="True" Font-Names="Verdana" ForeColor="#993300" />
    <div id="txt2" style="width:250px; height:22px; border:0px; margin:0px; padding-top:15px; padding-right:1px; float:left">
    <telerik:RadTextBox ID="txt_ricerca2" runat="server"
    EmptyMessage="Città di residenza" Width="250px" Height="22px" Skin=""
    Font-Italic="True" Font-Names="Verdana">
    <EmptyMessageStyle ForeColor="Gray" Font-Italic="True" Font-Names="Verdana" />
    <HoveredStyle Font-Italic="True" Font-Names="Verdana" ForeColor="#993300" />
    <div id="btn" style="width:80px; height:40px; border:0px; margin:0px; padding-top:7px; float:right">
    <asp:ImageButton ID="ImageButtonRicerca" runat="server"
    ImageUrl="~/Image/search.png" Width="48px" />
    <div id="menu" class="divresultmenu">
    <div class="divbuttonmenu">
    <telerik:RadButton ID="btnhome" runat="server" Text="Home page" Width="80px" Skin="Office2010Silver">
    <telerik:RadButton ID="btnreg" runat="server" Text="Registrati in trycontact" Width="180px" Skin="Office2010Silver">
    </div> <!-- end div menu -->
    <div class="resultseparator">
    <asp:Label ID="Label1" runat="server" class="lbresult" Text="Biglietti da visita trovati:"
    style="font-size: x-small; font-family: Verdana" ForeColor="#999999"></asp:Label>
    </div> <!-- end div separator -->
    <asp:Panel ID="PanelRadlist" runat="server" Width="700px">
    <div id="div_radlistview" class="divradlistview">
    <telerik:RadListView ID="RadListView1" runat="server" DataKeyNames="idutente"
    ItemPlaceholderID="Contenitore" AllowPaging="True"
    Width="650px" >
    <fieldset style="width: 700px; border:0px" id="FieldSet1">
    <asp:Panel ID="Contenitore" runat="server">
    <telerik:RadDataPager ID="RadDataPager1" runat="server"
    PagedControlID="RadListView1" Width="700px" Culture="it-IT" BackColor ="#ecede5">
    <telerik:RadDataPagerButtonField FieldType="FirstPrev"></telerik:RadDataPagerButtonField>
    <telerik:RadDataPagerButtonField FieldType="Numeric"></telerik:RadDataPagerButtonField>
    <telerik:RadDataPagerButtonField FieldType="NextLast"></telerik:RadDataPagerButtonField>
    <div class="item">
    <div class="image">
    <asp:Image ID="Image1" runat="server" ImageUrl='<%# CType(Container.DataItem, PropertyUtente).imageprofile%>' Height="120px" Width="110px"/>
    <div class="content">
    <div class="user">
    <div style="width:16px; height:16px; float:left; padding-right:3px">
    <img src="/image/icone/user1.png" alt="NP" />
    <b><%# CType(Container.DataItem, PropertyUtente).utente%></b>
    <div class="description_category">
    <div style="width:16px; height:16px; float:left; padding-right:3px">
    <img src="/image/icone/categoria.png" alt="NP" />
    </div> Categoria: <%# CType(Container.DataItem, PropertyUtente).Desccategoria%>
    <div class="description_city">
    <div style="width:16px; height:16px; float:left; padding-right:3px">
    <img src="/image/icone/home.png" alt="NP" />
    </div> Città: <%# CType(Container.DataItem, PropertyUtente).Desccomune%></div>
    <div class="description_email">
    <div style="width:16px; height:16px; float:left; padding-right:3px">
    <img src="/image/icone/email.png" alt="NP" />
    </div> Email: <%# CType(Container.DataItem, PropertyUtente).Email%>
    <div class="description_phone">
    <div style="width:16px; height:16px; float:left; padding-right:3px">
    <img src="/image/icone/telefono.png" alt="NP" />
    </div>Telefono: <%# CType(Container.DataItem, PropertyUtente).Telefono%></div>
    <div class="item_button">
    <telerik:RadButton ID="RadButton1" runat="server" Text="Biglietto completo" Width="140px" Skin="Office2010Silver"
    </div> <!-- end div radlist -->
    </div> <!-- end div banner -->
    </div> <!-- end div background -->

    vbnet code:

    Imports System
    Imports System.Web
    Imports System.Data
    Imports System.Data.SqlClient
    Imports Telerik.Web.UI
    Imports System.Web.UI.HtmlControls
    Imports System.IO
    Imports TRYcontact
    Public Class search
          Inherits RadAjaxPage
        Private ObjUtente As New PropertyUtente
        Private Loadsearch As New GestoreUtente
        Private Sub Carica_risultati(ByVal _str1 As String, ByVal _str2 As String)
            Dim list As List(Of PropertyUtente) = Loadsearch.Search(_str1, _str2)
            Cache("result") = list
            RadListView1.DataSource = list
        End Sub
        Protected Sub RadButton1_Click(sender As Object, e As System.EventArgs)
            Dim Button As RadButton = CType(sender, RadButton)
            Dim item As RadListViewDataItem = CType(Button.Parent, RadListViewDataItem)
            Session.Item("idutente") = item.GetDataKeyValue("idutente")
            'Dim script As String = "function f(){$find(""" + RadWindowCard.ClientID + """).show(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);"
            Session.Item("CurrentPageIndex") = RadListView1.CurrentPageIndex
        End Sub
        Private Sub ImageButtonRicerca_Click(sender As Object, e As System.Web.UI.ImageClickEventArgs) Handles ImageButtonRicerca.Click
            ScriptManager.RegisterStartupScript(Page, Me.GetType, "postback", "DoPostBack();", True)
            _search.Value = Txt_ricerca1.Text
            _search1.Value = txt_ricerca2.Text
            Carica_risultati(_search.Value, _search1.Value)
        End Sub
        Protected Sub search_Load(sender As Object, e As System.EventArgs) Handles Me.Load
            If Not Page.IsPostBack Then
                If Session("CurrentPageIndex") IsNot Nothing Then
                    RadListView1.DataSource = Cache("result")
                    RadListView1.CurrentPageIndex = Integer.Parse(Session("CurrentPageIndex").ToString())
                    Session("CurrentPageIndex") = Nothing
                    Exit Sub
                End If
                _search.Value = Request.QueryString("_str1")
                _search1.Value = Request.QueryString("_str2")
                Carica_risultati(_search.Value, _search1.Value)
            End If
        End Sub
        Protected Sub btnhome_Click(sender As Object, e As System.EventArgs) Handles btnhome.Click
        End Sub
        Protected Sub RadListView1_PageIndexChanged(sender As Object, e As Telerik.Web.UI.RadListViewPageChangedEventArgs) Handles RadListView1.PageIndexChanged
            If Cache("result") IsNot Nothing Then
                RadListView1.DataSource = Cache("result")
                Exit Sub
            End If
            Carica_risultati(_search.Value, _search1.Value)
        End Sub
    End Class

    help me

  2. Kostadin
    Kostadin avatar
    1693 posts

    Posted 13 Mar 2013 Link to this post

    Hi Fabio,

    It hard to determine the reason for that behavior as the code is not runnable. As far as I can see you are using Advanced DataBinding in your project. Note that you should never call DataBind() when using advanced data-binding through NeedDataSource. Instead DataBind() you have to call Rebind() method.

    All the best,
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. Telerik UI for ASP.NET Core is out
Back to Top