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

Radlistview and data caching

1 Answer 114 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Fabio Cirillo
Top achievements
Rank 1
Fabio Cirillo asked on 08 Mar 2013, 10:53 AM
hi,
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() {
__doPostBack();
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="ImageButtonRicerca">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="Panel1"
LoadingPanelID="RadAjaxLoadingPanel1" />
</UpdatedControls>
</telerik:AjaxSetting>
<telerik:AjaxSetting AjaxControlID="RadListView1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadWindowCard"
LoadingPanelID="RadAjaxLoadingPanel1" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadNotification ID="RadNotification1" runat="server" Height="100px"
Skin="Simple" TitleIcon="~/Image/iconlogo.png" Width="400px"
AutoCloseDelay="3500" Position="Center" Title="Notifica trycontact">
</telerik:RadNotification>
<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">
</telerik:RadAjaxLoadingPanel>
<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"
Font-Names="Verdana">
<EmptyMessageStyle ForeColor="Gray" Font-Italic="True" Font-Names="Verdana" />
<HoveredStyle Font-Italic="True" Font-Names="Verdana" ForeColor="#993300" />
</telerik:RadTextBox>
</div>
<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" />
</telerik:RadTextBox>
</div>
<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>
</asp:Panel>
</div>
</div>
<div id="menu" class="divresultmenu">
<div class="divbuttonmenu">
<telerik:RadButton ID="btnhome" runat="server" Text="Home page" Width="80px" Skin="Office2010Silver">
</telerik:RadButton>
<telerik:RadButton ID="btnreg" runat="server" Text="Registrati in trycontact" Width="180px" Skin="Office2010Silver">
</telerik:RadButton>
</div>
</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" >
<LayoutTemplate>
<fieldset style="width: 700px; border:0px" id="FieldSet1">
<legend></legend>
<asp:Panel ID="Contenitore" runat="server">
</asp:Panel>
<telerik:RadDataPager ID="RadDataPager1" runat="server"
PagedControlID="RadListView1" Width="700px" Culture="it-IT" BackColor ="#ecede5">
<Fields>
<telerik:RadDataPagerButtonField FieldType="FirstPrev"></telerik:RadDataPagerButtonField>
<telerik:RadDataPagerButtonField FieldType="Numeric"></telerik:RadDataPagerButtonField>
<telerik:RadDataPagerButtonField FieldType="NextLast"></telerik:RadDataPagerButtonField>
</Fields>
</telerik:RadDataPager>
</fieldset>
</LayoutTemplate>
<ItemTemplate>
<div class="item">
<div class="image">
<asp:Image ID="Image1" runat="server" ImageUrl='<%# CType(Container.DataItem, PropertyUtente).imageprofile%>' Height="120px" Width="110px"/>
</div>
<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" />
</div>
<b><%# CType(Container.DataItem, PropertyUtente).utente%></b>
</div>
<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>
<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>
<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"
OnClick="RadButton1_Click">
</telerik:RadButton>
</div>
</div>
</div>
</ItemTemplate>
</telerik:RadListView>
</div> <!-- end div radlist -->
</asp:Panel>
</div> <!-- end div banner -->
</div> <!-- end div background -->
</div>
</form>
</body>
</html>

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
        RadListView1.DataBind()
    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
        Response.Redirect("publicard.aspx")
    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())
                RadListView1.Rebind()
                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
        Response.Redirect("index.aspx")
    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

bye

1 Answer, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 13 Mar 2013, 11:49 AM
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,
Kostadin
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.
Tags
ListView
Asked by
Fabio Cirillo
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Share this question
or