Ajax - Rotator : Why display jpeg is not the first one?
I have 16 jpeg files for display
Each time show one jpeg only.
I use the sqldatasource to testing the result is correct .
Also I add the get item to display the counter of the item
The result
---------------------
The start screen
jpeg (this is the no.15 jpeg)
1/16
--------------------
press the forward button
jpeg (this is the no.16 jpeg)
16/16
-------------------
press the forward button
jpeg (this is the no.1 jpeg)
1/16
---------------------
Question:
1) Why the rotator first display is the no.15 jpeg not the first one jpeg.
2) When I try using WrapFrames="false" , the last jpeg is blank.
source:
-----------------------------
<span class="title"><telerik:RadRotator ID="RadRotatorHorizontal"
runat="server" DataSourceID="SqlDataSource1"
RotatorType="FromCode" Height="480px"
Width="1471px" ItemHeight="480px" ItemWidth="1200px" scrollduration="1" frameduration="2000"
ScrollDirection="Right"
CssClass="floatRotator" OnClientItemShown="OnClientItemShown" >
<ItemTemplate>
<div class="itemTemplate">
<asp:Image runat="server" ID="Image"
ImageUrl='<%# Eval("ImageURL_Full_FileName") %>'
CssClass="displayimage" AlternateText="Customer Image" Height="455px"
Width="1200px"/>
<br />
<asp:sqldatasource id="SqlDataSource1" runat="server" connectionstring="<%$
ConnectionStrings:ConnectionString9 %>"
selectcommand="SELECT * FROM [Cam_Recording] ORDER BY [ImageURL_Full_FileName]"
ProviderName="<%$ ConnectionStrings:ConnectionString9.ProviderName %>">
</asp:sqldatasource>
function OnClientItemShown(sender, args) {
var textitem = (args.get_item().get_index() + 1) + "/" + (sender.get_items().length);
var Label5value = document.getElementById("Label5");
Label5value.innerHTML = textitem;
}
-----------------------------
Thanks!!!
| <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Exp.aspx.cs" Inherits="Exp" MasterPageFile="~/MasterPage.master" %> |
| <%@ MasterType VirtualPath="~/MasterPage.master" %> |
| <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server" > |
| <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"> |
| <script type="text/javascript"> |
| //<![CDATA[ |
| function updateTreeView() { |
| var update = document.getElementById('<%= hdnOperationType.ClientID %>'); |
| if (update) { |
| if (update.value == "nodeadded") { |
| update.value = ""; |
| var newParent = document.getElementById('<%= hdnOperationSource.ClientID %>'); |
| updateAffectedNode(newParent.value); |
| } |
| else { |
| if (update.value == "nodeedited") { |
| update.value = ""; |
| var target = document.getElementById('<%= hdnOperationSource.ClientID %>'); |
| updateAffectedNode(target.value); |
| } |
| } |
| } |
| } |
| ...more javascript here |
| //]]> |
| </script> |
| </telerik:RadCodeBlock> |
| <asp:HiddenField ID="hdnOperationType" runat="server" /> |
| <asp:HiddenField ID="hdnOperationSource" runat="server" /> |
| <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> |
| <AjaxSettings> |
| <telerik:AjaxSetting AjaxControlID="RadTreeView1"> |
| <UpdatedControls> |
| <telerik:AjaxUpdatedControl ControlID="tvExplorer" /> |
| <telerik:AjaxUpdatedControl ControlID="pnlDetail" /> |
| <telerik:AjaxUpdatedControl ControlID="hdnOperationSource" /> |
| <telerik:AjaxUpdatedControl ControlID="hdnOperationType" /> |
| </UpdatedControls> |
| </telerik:AjaxSetting> |
| <telerik:AjaxSetting AjaxControlID="UpdatePanel1"> |
| <UpdatedControls> |
| <telerik:AjaxUpdatedControl ControlID="tvExplorer" /> |
| <telerik:AjaxUpdatedControl ControlID="pnlDetail" /> |
| <telerik:AjaxUpdatedControl ControlID="hdnOperationSource" /> |
| <telerik:AjaxUpdatedControl ControlID="hdnOperationType" /> |
| </UpdatedControls> |
| </telerik:AjaxSetting> |
| </AjaxSettings> |
| </telerik:RadAjaxManager> |
| <telerik:RadSplitter ID="RadSplitter1" CssClass="grid_12" Height="650" Width="100%" LiveResize="true" runat="server"> |
| <telerik:RadPane ID="pnlExplorer" Height="100%" Width="300" runat="server"> |
| <telerik:RadTreeView ID="tvExplorer" runat="server" TabIndex="1" AccessKey="m" |
| OnClientLoad="updateTreeView" |
| OnClientContextMenuItemClicking="OnClientContextMenuItemClicking" |
| OnClientKeyPressing="OnClientKeyPressing" |
| OnNodeClick="tvExplorer_NodeClick" |
| OnContextMenuItemClick="tvExplorer_ContextMenuItemClick" |
| > |
| <WebServiceSettings Path="DataSvcProxy.asmx" Method="GetRadTreeViewNodes" /> |
| <Nodes> |
| <telerik:RadTreeNode runat="server" Text="Root Node" Value="0" ClassID="0" PermClasses="0" ExpandMode="WebService" /> |
| </Nodes> |
| </telerik:RadTreeView> |
| </telerik:RadPane> |
| <telerik:RadSplitBar ID="RadSplitBar1" CollapseMode="Forward" runat="server" /> |
| <telerik:RadPane ID="pnlDetail" Height="100%" Width="100%" runat="server"> |
| <asp:UpdatePanel ID="updDetail" runat="server" UpdateMode="Conditional" > |
| <ContentTemplate> |
| <div class="emptyItem"> |
| Select an item in the left pane to view its information in this pane. |
| </div> |
| </ContentTemplate> |
| </asp:UpdatePanel> |
| </telerik:RadPane> |
| </telerik:RadSplitter> |
| </asp:Content> |
<
telerik:RadEditor ID="radEditor" runat="server"
Skin="WWRDefault" EnableEmbeddedSkins="false"
ToolbarMode="Default" Height="600px" Width="97%"
Visible="false" CausesValidation="False"
ToolsFile="~/DefaultRadEditorToolsFile.xml"
MaxDocumentSize="2400000" MaxImageSize="20480"
ImagesFilters="*.png,*.gif,*.jpg,*.jpeg"
DocumentsFilters="*.pdf,*.xls" />
| if (this.ContentAwarePager != null) |
| { |
| AjaxUpdatedControl ucgrid = new AjaxUpdatedControl(); |
| ucgrid.ControlID = this.ID; |
| AjaxUpdatedControl ucpager = new AjaxUpdatedControl(); |
| ucpager.ControlID = (this.ContentAwarePager as WebControl).ID; |
| AjaxSetting gridtopager = new AjaxSetting(); |
| gridtopager.AjaxControlID = this.ID; |
| gridtopager.UpdatedControls.Add(ucgrid); |
| gridtopager.UpdatedControls.Add(ucpager); |
| ram.AjaxSettings.Add(gridtopager); |
| AjaxSetting pagertogrid = new AjaxSetting(); |
| gridtopager.AjaxControlID = (this.ContentAwarePager as WebControl).ID; |
| gridtopager.UpdatedControls.Add(ucgrid); |
| gridtopager.UpdatedControls.Add(ucpager); |
| ram.AjaxSettings.Add(pagertogrid); |
| } |
| sub bindgrid() Dim d As DataTable = CType(Cache("MyCache"), Data.DataTable) |
| If d Is Nothing Then |
| d = functions.dt("Select top 100* from table") |
| Cache.Insert("MyCache", d, Nothing, DateTime.Now.AddSeconds(30), TimeSpan.Zero) |
| status.innerhtml = "data loaded from database" |
| Else |
| status.innerhtml = "Data loaded from cache" |
| End If |
| RadGrid1.DataSource = d end sub |
I am calling the sub from within the needdatasource event. so now the grid loads either cached or fresh data. I am handling paging via calling bindgrid() again and setting pageindex to newpageindex.
This works fine. When I go into edit mode and incorporate the GridEditableitem method and update the selected row this also works fine except that the cached data now no longer matches the updated data. until the cache is rebuilt or I manually remove the cache on updated.
| If e.CommandName = "Update" Then |
| Dim ei As GridEditableItem = TryCast(e.Item, GridEditableItem) |
| Dim pk As String = ei.OwnerTableView.DataKeyValues(ei.ItemIndex)("keyid").ToString() |
| Dim empid As String = TryCast(ei("Emp_ID").Controls(0), TextBox).Text |
| Dim sql As String = "update table set emp_id = '" & empid & "' where keyid = " & pk |
| functions.Scalar(sql) |
| Cache.Remove("MyCache") 'If I don't kill the cache I end up with the old values. |
| bindgrid() |
| End If |
Do you have any method or trick to updating the grid to the new values without having to rebuild the cache? I suppose I could somehow extract the datatable from the cache, loop through the datatable, find the affected row, somehow update the column and reset the grid... but that seems pretty laborious.