Dec 16, 2009, 6:39 PM
[CLOSED] problem with dynamic store on postback
Hi
I am building page wich creates store and gridpanel dynamically. Everything works when page loads. I have a button on grid which calls grid.reload(); when that happens, i get the following error. Do i need to use reconfigure on AjaxEvent. How I can make sure that my grid reloads on AjaxEvent Thanks - Idriss
An exception of type 'System.Web.HttpException' occurred in Coolite.Ext.Web.DLL but was not handled in user code</p>
Additional information: The control with ID 'store1' not found
this is coming from scriptManager.cs
aspx page</p>
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="tblproperties.aspx.cs" Inherits="tblproperties" %></p>
<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %></p>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></p>
<html xmlns="http://www.w3.org/1999/xhtml"></p>
<head runat="server" id="Head1"></p>
<ext:ScriptContainer ID="ScriptContainer1" runat="server" ></p>
<link href='<%= ResolveUrl("~/css/panel.css") %>' rel="stylesheet" type="text/css" /></p>
</ext:ScriptContainer></p>
<script src="../JavaScript/jquery-1.3.2.min.js" type="text/javascript"></script></p>
</head></p>
<body></p>
<form id="theForm" runat="server"></p>
</p>
<asp:PlaceHolder runat="server" ID="ph1"></asp:PlaceHolder></p>
</p>
<ext:ScriptManager ID="ScriptManager1" runat="server"></p>
</ext:ScriptManager></p>
</p>
<asp:HiddenField ID="hfSection" EnableViewState="true" runat="server" /></p>
</p>
</p>
<ext:ViewPort ID="ViewPort1" runat="server"></p>
<Body></p>
<ext:BorderLayout ID="BorderLayout1" runat="server"></p>
<North MarginsSummary="5 5 5 5"></p>
<ext:Panel ID="pnlTop" runat="server" Header="false" Frame="true" AutoHeight="true"</p>
BodyStyle="padding: 5px;background-color:#ffffff;" ></p>
<Body></p>
<div ></p>
<div style="float: left; width: 49%;"></p>
<label class="tdText"></p>
<input type="checkbox" id="cbComplete" onclick="changeIcon(this, document.getElementById('hfSection').value)" />Mark</p>
this section as complete and accurate</label></p>
</p>
</p>
<br /></p>
<div style="width: 100%;"></p>
<!-- BEGIN EXPAND --></p>
<wc:wc_Expander runat="server" ID="expand1" MessageHeader="Additional Information" </p>
MessageBody="Please review the information below. To view additional information on a specific</p>
item or to change any of the information displayed, click on Change. For any numerical</p>
fields, enter only whole numbers - do not enter dollar signs, decimal points or</p>
commas. When finished, click on Save. To add a new item, click on Add New button</p>
at the top of the form. To delete an item, click on Remove. Once you are finished</p>
reviewing all the information, click the box next to Mark this section as complete</p>
and accurate. For additional help, click on the Instructions tab." /></p>
<!-- END EXPAND --></p>
</p>
</p>
</Body></p>
</ext:Panel></p>
</North></p>
<Center MarginsSummary="0 5 5 5"></p>
<ext:Panel ID="pnlBottom" runat="server" Frame="true" Header="false"></p>
<Body></p>
</Body></p>
</ext:Panel></p>
</Center></p>
</ext:BorderLayout></p>
</Body></p>
</ext:ViewPort></p>
</p>
</p>
</p>
</p>
</form></p>
</body></p>
</html>
code behind simplified </p>
using System;</p>
using System.Collections.Generic;</p>
using System.Web;</p>
using System.Web.UI;</p>
using System.Web.UI.WebControls;</p>
using log4net;</p>
using Resources;</p>
using System.Linq;</p>
using D2D.Extensions;</p>
using IFG.Data.NavRisk;</p>
using Coolite.Ext.Web;
</p>
public partial class tblproperties: IFG.Web.PageBase</p>
{</p>
public string PolicyID </p>
{</p>
get</p>
{</p>
object obj = ViewState["PolicyID"];</p>
return (obj == null) ? string.Empty : (string)obj;</p>
}</p>
set</p>
{</p>
ViewState["PolicyID"] = value;</p>
} </p>
}</p>
protected void Page_Load(object sender, EventArgs e)</p>
{ </p>
if (!IsPostBack && !Ext.IsAjaxRequest)</p>
{</p>
PolicyID = IFG.Data.NavRiskController.GetPolicyID(this.IFG_CurrentMemberID);</p>
CreateGrid();</p>
} </p>
}</p>
protected void GridRefresh(object sender, StoreRefreshDataEventArgs e)</p>
{</p>
CreateGrid();</p>
}</p>
private void CreateGrid()</p>
{</p>
</p>
Dictionary<string, IFG.WebControls.DataBoundField> listColumns = CreateColumnsCollection<Properties>();</p>
HttpContext.Current.Cache["listcolumns"] = listColumns;</p>
Store store = new Store { ID = "store1" };</p>
this.ph1.Controls.Add(store);</p>
</p>
store.RefreshData += new Store.AjaxRefreshDataEventHandler(GridRefresh);</p>
store.AutoLoad = true;</p>
store.Reader.Add(new JsonReader());</p>
#region Grid Definition</p>
GridPanel grid = new GridPanel</p>
{</p>
ID = "grid2",</p>
AutoScroll = true,</p>
//AutoHeight = true,</p>
StoreID = store.ID,</p>
StripeRows = true,</p>
Header = false,</p>
AutoWidth = true</p>
};</p>
grid.LoadMask.ShowMask = true;</p>
grid.LoadMask.Msg = "Loading...";</p>
FitLayout fit1 = new FitLayout();</p>
fit1.Items.Add(grid);</p>
</p>
pnlBottom.BodyControls.Add(fit1);</p>
Coolite.Ext.Web.PagingToolbar pager = new Coolite.Ext.Web.PagingToolbar { PageSize = 20 };</p>
grid.BottomBar.Add(pager);</p>
Coolite.Ext.Web.Toolbar tb = new Coolite.Ext.Web.Toolbar();</p>
Coolite.Ext.Web.ToolbarButton button = new Coolite.Ext.Web.ToolbarButton();</p>
button.ID = "btnAdd";</p>
button.Text = "Add New";</p>
button.Icon = Icon.Add;</p>
tb.Items.Add(button);</p>
button = new Coolite.Ext.Web.ToolbarButton();</p>
button.ID = "btnExport"; </p>
button.Text = "Export";</p>
button.Icon = Icon.HtmlGo;</p>
tb.Items.Add(button);</p>
button = new Coolite.Ext.Web.ToolbarButton();</p>
button.ID = "btnRefresh";</p>
button.Text = "Refresh";</p>
button.AutoPostBack = false;</p>
button.Icon = Icon.ArrowRefresh;</p>
button.Listeners.Click.Handler = "grid2.reload();";</p>
tb.Items.Add(button);</p>
</p>
grid.TopBar.Add(tb);</p>
#endregion</p>
#region Create Reader for Store</p>
((Coolite.Ext.Web.JsonReader)store.Reader[0]).ReaderID = "reader1";</p>
Coolite.Ext.Web.RecordField field = null;</p>
field = new Coolite.Ext.Web.RecordField("col1", Coolite.Ext.Web.RecordFieldType.Auto);</p>
field = new Coolite.Ext.Web.RecordField("col2", Coolite.Ext.Web.RecordFieldType.Auto);</p>
#endregion
</p>
</p>store.Reader[0].Fields.Add(field);
</p>
Coolite.Ext.Web.Column _col = new Coolite.Ext.Web.Column</p>
{</p>
ColumnID = cc.ColumnName,</p>
Header = cc.ColumnHeader,</p>
DataIndex = cc.ColumnName,</p>
Sortable = cc.IsSortable,</p>
Width = 100,</p>
Hidden = false</p>
};</p>
</p>
</p>grid.ColumnModel.Columns.Add(_col);
</p>
</p>
}</p>
// if we need to add Edit/Delete columns</p>
Coolite.Ext.Web.CommandColumn commandColumn = new Coolite.Ext.Web.CommandColumn { ColumnID = "actionButton", Header = "Action", DataIndex = "ActionButton", Sortable = false, Width = 80 };</p>
Coolite.Ext.Web.GridCommand deleteColumn = new Coolite.Ext.Web.GridCommand { Icon = Icon.Delete, CommandName = "Delete" };</p>
Coolite.Ext.Web.CommandSeparator sepColumn = new CommandSeparator();</p>
Coolite.Ext.Web.GridCommand editColumn = new Coolite.Ext.Web.GridCommand { Icon = Icon.NoteEdit, CommandName = "Edit" };</p>
commandColumn.Commands.Add(deleteColumn);</p>
commandColumn.Commands.Add(sepColumn);</p>
commandColumn.Commands.Add(editColumn);</p>
grid.ColumnModel.Columns.Add(commandColumn);</p>
#endregion</p>
col = IFG.Data.RQController.GetProperties(PolicyID);</p>
store.DataSource = col;</p>
store.DataBind();</p>
</p>
}</p>
</p>
</p>
</p>
}
</p>