Problem handling DataGrid TemplateColumn Databinding Event
I have spent several hours trying to research and/or fix the following
I have a dynamically generated DataGrid (all columns are
templatecolumns added at runtime). One of the columns contains a
custom control. In the InstantiateIn method of my
1) Create a deep copy instance of the custom control (provided via a
TemplateColumnFactory construction parameter),
2) Add a DataBind event handler for the custom control,
3) Add the control to the templatecolumn.
In the associated DataBind eventhandler (also located in the
TemplateColumnFactory) I raise a Public Shared event which exposes the
DatabBinding of the custom control to the, in this case, aspx
code-behind (web Page - which has already added an EventHandler for
the Shared event).
Control DataBind --> Factory raiseEvent --> aspx EventHandler
This all works great the first time...
On each subsequent postback, the aspx EventHandler handles the rasied
event an incremental number of times for each control in the DataGrid
First postBack aspx EventHandler handles the raised event twice
Second postback aspx EventHandler handles the raised event three time
and so on...
First I really need to understand why this is happening. Second, I
really need to get this fixed quickly.
Re: Problem handling DataGrid TemplateColumn Databinding Event
OK, here's what I did (as a work-around)...
Instead of attaching a DataBinding eventHandler in the InstantiateIn
method of the TemplateColumnFactory (for the custom control) I used
the ItemDataBound event on the Datagrid to process/hydrate the Custom
control in the DataGrid TemplateColumn (from the .aspx code-behind).
This effectively eliminated the redundant event processing. While this
"solution" will keep me moving along I would really like to understand
why this redundant event processing occurred. Ideally, I'd like to
publish the databinding event for the custom control (this would be
far more intuitive for other consumers of the TemplateColumnFactory).
I hope that someone has some thoughts/ideas.
|All times are GMT. The time now is 09:43 AM.|
Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.