I have a grid that does not update automaticly after I deleted an item. However, if I click on the refresh button, the item has been removed from de grid. I placed the grid in a RadAjaxLoadingPanel, but it's not working. Can someone help me?
This is my ascx code:
| <%@ Control language="vb" Inherits="BDB.Modules.BDB_Promo_Settings.ViewBDB_Promo_Settings" CodeFile="ViewBDB_Promo_Settings.ascx.vb" AutoEventWireup="false" Explicit="True" %> |
| <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> |
| <%@ Register TagPrefix="dnn" TagName="Audit" Src="~/controls/ModuleAuditControl.ascx" %> |
| <telerik:RadAjaxLoadingPanel ID="radLoadingPromo" runat="server" Height="75px" Width="75px"> |
| <img alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>' |
| style="border: 0px;" /> |
| </telerik:RadAjaxLoadingPanel> |
| <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" Height="100%" Width="100%" EnableAJAX="true" LoadingPanelID="radLoadingPromo"> |
| <telerik:RadGrid ID="gridPromo" runat="server" AutoGenerateColumns="False" EnableAJAX="true" |
| GridLines="None" AllowAutomaticDeletes="true" OnDeleteCommand="gridPromo_DeleteCommand" |
| EnableEmbeddedSkins="False" Skin="BDB"> |
| <HeaderContextMenu EnableTheming="True"> |
| <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> |
| </HeaderContextMenu> |
| <MasterTableView> |
| <RowIndicatorColumn> |
| <HeaderStyle Width="20px"></HeaderStyle> |
| </RowIndicatorColumn> |
| <ExpandCollapseColumn> |
| <HeaderStyle Width="20px"></HeaderStyle> |
| </ExpandCollapseColumn> |
| <Columns> |
| <telerik:GridBoundColumn DataField="PromoId" HeaderText="ID" UniqueName="ID" |
| Visible="False"> |
| </telerik:GridBoundColumn> |
| <telerik:GridTemplateColumn HeaderText="Afbeelding" UniqueName="Afbeelding" DataField="Folder"> |
| <ItemTemplate> |
| <asp:Image ID="afbPromo" runat="server" /> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridBoundColumn DataField="Alt" HeaderText="Alt" UniqueName="Alt"> |
| </telerik:GridBoundColumn> |
| <telerik:GridButtonColumn ConfirmText="Wilt u deze afbeelding verwijderen?" ButtonType="ImageButton" ImageUrl="~/images/action_delete.gif" CommandName="Delete" Text="Delete" UniqueName="DeleteColumn" > |
| </telerik:GridButtonColumn> |
| <telerik:GridBoundColumn DataField="Folder" HeaderText="Folder" |
| UniqueName="Folder" Visible="False"> |
| </telerik:GridBoundColumn> |
| </Columns> |
| <EditFormSettings> |
| <EditColumn CancelImageUrl="Cancel.gif" EditImageUrl="Edit.gif" |
| InsertImageUrl="Update.gif" UpdateImageUrl="Update.gif"> |
| </EditColumn> |
| </EditFormSettings> |
| </MasterTableView> |
| <FilterMenu EnableTheming="True"> |
| <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> |
| </FilterMenu> |
| </telerik:RadGrid> |
| <br /> |
| <span style="float:right"> |
| <asp:ImageButton ID="imgbuRefresh" ImageUrl="~/images/action_refresh.gif" runat="server" /> |
| <asp:ImageButton ID="imgBuAdd" ImageUrl="~/Portals/_default/Skins/BDB-Blue/images/add.gif" runat="server" /> |
| </span> |
| </telerik:RadAjaxPanel> |
| <telerik:RadWindowManager ID="windowMgrPromo" runat="server" Animation="Resize" |
| DestroyOnClose="True"> |
| <Windows> |
| <telerik:RadWindow ID="windowPromo" runat="server" Skin="Forest" NavigateUrl="PromoUpload.aspx" VisibleStatusbar="False" VisibleTitlebar="True" Height="300" Width="700"> |
| </telerik:RadWindow> |
| <telerik:RadWindow ID="windowMessage" runat="server"></telerik:RadWindow> |
| </Windows> |
| </telerik:RadWindowManager> |
| <asp:Label ID="lblTest" runat="server"></asp:Label> |
And this is my code-behind:
| ' |
| ' DotNetNuke® - http://www.dotnetnuke.com |
| ' Copyright (c) 2002-2006 |
| ' by Perpetual Motion Interactive Systems Inc. ( http://www.perpetualmotion.ca ) |
| ' |
| ' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated |
| ' documentation files (the "Software"), to deal in the Software without restriction, including without limitation |
| ' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and |
| ' to permit persons to whom the Software is furnished to do so, subject to the following conditions: |
| ' |
| ' The above copyright notice and this permission notice shall be included in all copies or substantial portions |
| ' of the Software. |
| ' |
| ' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED |
| ' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| ' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF |
| ' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| ' DEALINGS IN THE SOFTWARE. |
| ' |
| Imports DotNetNuke |
| Imports System.Web.UI |
| Imports System.Collections.Generic |
| Imports System.Reflection |
| Imports Telerik.Web.UI |
| Imports System.IO |
| Namespace BDB.Modules.BDB_Promo_Settings |
| ''' ----------------------------------------------------------------------------- |
| ''' <summary> |
| ''' The ViewDynamicModule class displays the content |
| ''' </summary> |
| ''' <remarks> |
| ''' </remarks> |
| ''' <history> |
| ''' </history> |
| ''' ----------------------------------------------------------------------------- |
| Partial Class ViewBDB_Promo_Settings |
| Inherits Entities.Modules.PortalModuleBase |
| Implements Entities.Modules.IActionable |
| #Region "Private Members" |
| Private colBDB_Promo_Settings As List(Of BDB_Promo_SettingsInfo) |
| #End Region |
| #Region "Event Handlers" |
| ''' ----------------------------------------------------------------------------- |
| ''' <summary> |
| ''' Page_Load runs when the control is loaded |
| ''' </summary> |
| ''' <remarks> |
| ''' </remarks> |
| ''' <history> |
| ''' </history> |
| ''' ----------------------------------------------------------------------------- |
| Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load |
| Dim _controller As New BDB_Promo_SettingsController |
| colBDB_Promo_Settings = _controller.GetAllBDB_Promo_Settings() |
| windowPromo.VisibleOnPageLoad = True |
| windowPromo.Visible = False |
| End Sub |
| Protected Sub imgBuAdd_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgBuAdd.Click |
| windowPromo.Visible = True |
| End Sub |
| Protected Sub imgbuRefresh_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgbuRefresh.Click |
| gridPromo.DataSource = colBDB_Promo_Settings |
| gridPromo.DataBind() |
| End Sub |
| Protected Sub gridPromo_DeleteCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles gridPromo.DeleteCommand |
| If (e.CommandName = "Delete") Then |
| Try |
| ' Remove record from database |
| Dim data As GridDataItem |
| data = e.Item |
| Dim _controller As New BDB_Promo_SettingsController |
| _controller.DeleteBDB_Promo_Settings(CType(data.Item("ID").Text, Integer)) |
| ' Remove image from hard disk |
| If File.Exists(data.Item("Folder").Text) Then |
| File.Delete(data.Item("Folder").Text) |
| End If |
| gridPromo.Rebind() |
| lblTest.Text = "De afbeelding is verwijderd." |
| lblTest.Visible = True |
| Catch ex As Exception |
| lblTest.Text = "Er is een fout opgetreden bij het verwijderen van de afbeelding." |
| lblTest.Visible = True |
| End Try |
| End If |
| End Sub |
| Protected Sub gridPromo_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles gridPromo.NeedDataSource |
| gridPromo.DataSource = colBDB_Promo_Settings |
| 'gridPromo.DataBind() |
| End Sub |
| Protected Sub gridPromo_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles gridPromo.PreRender |
| Dim gridRows As GridItemCollection = gridPromo.Items |
| Dim obj As BDB.Modules.BDB_Promo_Settings.BDB_Promo_SettingsInfo |
| Dim afbeelding As System.Web.UI.WebControls.Image |
| Try |
| For Each data As GridDataItem In gridRows |
| obj = data.DataItem |
| afbeelding = CType(data.FindControl("afbPromo"), System.Web.UI.WebControls.Image) |
| afbeelding.ImageUrl = obj.Lokatie |
| afbeelding.ToolTip = obj.Alt |
| 'afbeelding.Height = 100 |
| 'afbeelding.Width = 400 |
| Next |
| Catch ex As Exception |
| End Try |
| End Sub |
| #End Region |
| #Region "Optional Interfaces" |
| ''' ----------------------------------------------------------------------------- |
| ''' <summary> |
| ''' Registers the module actions required for interfacing with the portal framework |
| ''' </summary> |
| ''' <value></value> |
| ''' <returns></returns> |
| ''' <remarks></remarks> |
| ''' <history> |
| ''' </history> |
| ''' ----------------------------------------------------------------------------- |
| Public ReadOnly Property ModuleActions() As Entities.Modules.Actions.ModuleActionCollection Implements Entities.Modules.IActionable.ModuleActions |
| Get |
| Dim Actions As New Entities.Modules.Actions.ModuleActionCollection |
| Actions.Add(GetNextActionID, Localization.GetString(Entities.Modules.Actions.ModuleActionType.AddContent, LocalResourceFile), Entities.Modules.Actions.ModuleActionType.AddContent, "", "", EditUrl(), False, Security.SecurityAccessLevel.Edit, True, False) |
| Return Actions |
| End Get |
| End Property |
| #End Region |
| End Class |
| End Namespace |