|
Rank: Advanced Member Groups: Member
Joined: 5/19/2010 Posts: 35
|
Hi,
I have a page which dynamically loads EO.Grid objects based on which tab is selected. So far this all works correctly including changing it to edit mode for editting, however upon saving the Added/Changed/Deleted items are registering as empty: I've set it so it displays "No items have changed" if all 3 of these lists are empty, and it seems to do this every time.
The grid works perfectly on another page where it hasn't been dynamically generated, any idea what might be the cause of this? Thanks.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, One of the principle for dynamic loading is that you have to reload the same control when the page posts back at very early stage of the page's life cycle (for example, inside OnInit). So please check that first. Here is another page post about the CallbackPanel control but about the same dynamic loading issue: http://www.essentialobjects.com/forum/postst4243_Callback-was-initially-dynamically-loaded.aspxThanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 5/19/2010 Posts: 35
|
Hi, Thanks for your reply. I'd previously found that topic, and as far as I can tell I've followed the basic rules as far as dynamically loading controls goes. I'd previously had the 'initially dynamically loaded' error when trying to change the grid to edit mode but fixed it. Here's more or less what I've got:
Code: JavaScript
function SwitchTab(e, info) {
eo_Callback('<%=EditCallbackPanel.ClientID%>', info.getItem().getIndex().toString());
}
function OnAfterControlLoaded(cb, extraData) {
eo_Callback('EditCallbackPanel');
}
Code: HTML/ASPX
<eo:CallbackPanel runat="server"
id="EditCallbackPanel" Width="100%" Height="200px"
LoadingHTML="Loading..." ClientSideAfterUpdate="OnAfterControlLoaded">
</eo:CallbackPanel>
And on the codebehind:
Code: C#
protected void Page_Init(object sender, EventArgs e)
{
if (!EditCallbackPanel.IsCallbackByMe)
LoadPage(0);
}
Any idea what I might be missing? The save method basically just goes through addeditems/deleteditems/changeditems and applies whatever it needs to, but if it finds nothing in all 3 then it displays "No item has changed", which it is doing every time on the dynamically generated page.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
We can't find much just by looking at those snippets. Can you post a full test page?
Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 5/19/2010 Posts: 35
|
Hi, Here's a shaved-down version of my page, with all the relevent code left intact. Hope this helps.
Code: HTML/ASPX
<%@ Page Language="C#" Theme="Default" MasterPageFile="~/MasterPages/admin.master" AutoEventWireup="true" CodeFile="RiskProfilesEdit.aspx.cs" Inherits="RiskProfilesEdit" Title="RiskProfiles Edit" %>
<%@ Register src="UserControls/ClientsGrid.ascx" tagname="ClientsGrid1" tagprefix="uc1"%>
<%@ Register TagPrefix="eo" NameSpace="EO.Web" Assembly="EO.Web" %>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">Risk Profiles - Add/Edit</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<script type="text/javascript">
function SwitchTab(e, info) {
eo_Callback('<%=EditCallbackPanel.ClientID%>', info.getItem().getIndex().toString());
}
function OnAfterControlLoaded(cb, extraData) {
eo_Callback('EditCallbackPanel');
}
</script>
<data:MultiFormView Enabled="false" ID="FormView1" DataKeyNames="RiskProfileId" runat="server">
<EditItemTemplatePaths>
<data:TemplatePath Path="~/Admin/UserControls/RiskProfilesFields.ascx" />
</EditItemTemplatePaths>
<InsertItemTemplatePaths>
<data:TemplatePath Path="~/Admin/UserControls/RiskProfilesFields.ascx" />
</InsertItemTemplatePaths>
<EmptyDataTemplate>
<b>RiskProfiles not found!</b>
</EmptyDataTemplate>
<FooterTemplate>
<asp:Button ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert" Text="Insert" />
<asp:Button ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update" Text="Update" />
<asp:Button ID="CancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</FooterTemplate>
</data:MultiFormView>
<eo:tabstrip id="TabStrip1" runat="server" ControlSkinID="None"
Width="100%" ClientSideOnItemClick="SwitchTab">
<TopGroup>
<Items>
<eo:TabItem ItemID="ClientsTab" Text-Html="Clients"></eo:TabItem>
<eo:TabItem ItemID="RiskProfilesAuditTab" Text-Html="RiskProfilesAudit"></eo:TabItem>
<eo:TabItem ItemID="ShareAccountsTab" Text-Html="ShareAccounts"></eo:TabItem>
<eo:TabItem ItemID="ClientsTab" Text-Html="Clients"></eo:TabItem>
</Items>
</TopGroup>
<LookItems>
<eo:TabItem Height="20" ItemID="_Default" RightIcon-Url="" NormalStyle-CssText="background-image:url('00020005');background-repeat:repeat-x;border-bottom-color:#B0B0B0;border-bottom-style:solid;border-bottom-width:1px;border-left-color:#B0B0B0;border-left-style:solid;border-left-width:1px;border-right-color:#B0B0B0;border-right-style:solid;border-right-width:1px;border-top-color:#B0B0B0;border-top-style:solid;border-top-width:1px;color:Gray;font-weight:normal;padding-left:5px;padding-right:5px;"
SelectedStyle-CssText="background-image:url('00020005');background-repeat:repeat-x;border-bottom-color:#b0b0b0;border-bottom-style:none;border-bottom-width:1px;border-left-color:#b0b0b0;border-left-style:solid;border-left-width:1px;border-right-color:#b0b0b0;border-right-style:solid;border-right-width:1px;border-top-color:#b0b0b0;border-top-style:solid;border-top-width:1px;color:Black;padding-left:5px;padding-right:5px;"
LeftIcon-Url="" Text-Padding-Top="1" Text-Padding-Bottom="2">
<SubGroup Style-CssText="background-image:url(00010601);background-position-y:bottom;background-repeat:repeat-x;color:black;cursor:hand;font-family:Verdana;font-size:11px;"
ItemSpacing="1"></SubGroup>
</eo:TabItem>
</LookItems>
</eo:tabstrip>
<eo:CallbackPanel runat="server" id="EditCallbackPanel" Width="100%" Height="200px" LoadingHTML="Loading...">
</eo:CallbackPanel>
<div style="BORDER-RIGHT:#b0b0b0 1px solid; BORDER-LEFT:#b0b0b0 1px solid; BORDER-BOTTOM:#b0b0b0 1px solid; padding: 5px 5px 5px 5px; width:100%;">
<br />
</asp:Content>
Code: C#
#region Imports...
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using EO.Web;
using ClientManager_CodeGenTables.Web.UI;
using ClientManager_CodeGenTables.Entities;
#endregion
public partial class RiskProfilesEdit : System.Web.UI.Page
{
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.EditCallbackPanel.Execute += new EO.Web.CallbackEventHandler(this.EditCallbackPanel_Execute);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
protected void Page_Init(object sender, EventArgs e)
{
if (!EditCallbackPanel.IsCallbackByMe)
LoadPage(0);
}
protected void Page_Load(object sender, EventArgs e)
{
}
public void LoadPage(int index)
{
System.Threading.Thread.Sleep(500);
if (index == 0)
{
ASP.ClientsGrid tabPageContent = (ASP.ClientsGrid)LoadControl("UserControls/ClientsGrid.ascx");
EditCallbackPanel.Controls.Add(tabPageContent);
}
}
private void EditCallbackPanel_Execute(object sender, EO.Web.CallbackEventArgs e)
{
LoadPage(int.Parse(e.Parameter));
}
}
|
|
Rank: Advanced Member Groups: Member
Joined: 5/19/2010 Posts: 35
|
I've refined this one down a little, it seems that when I hit edit on my grids the first grid is loaded and put into edit mode, despite which tab has been pressed. I'm however unable to find a way for the page to remember which tab has been pressed, is there any easy way to accomplish this?
Edit: Got this part sorted using Session variables, however the issue still remains. Even when the correct grid is being displayed before/after postback, it still doesn't register any added/changed/deleted items. Everything else seems to be working correctly though.
The Grid object is running in Client mode, would this affect it at all?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
Your code looks fine to us. There is really nothing else in term of dynamic loading. When you have a static page, ASP.NET compiler generates code that dynamically creates all controls based on your .aspx. So in a way all controls are always dynamically created. The only difference is whether it's created by your code or ASP.NET compiler generated code. Apparently there is no difference from the control's point of view regard whose code it is.
My suggestion is to try the same setup with an empty project and strip out as much as you can (for example, you don't have to use a CallbackPanel or TabStrip at the very beginning). If the problem still occurs with almost nothing left, then you can send the test project to us and we will be happy to take a look.
Client mode doesn't matter. As already explained earlier, there should be no difference for the Grid as to whose code loaded it.
Thanks!
|
|