How to expose an ITemplate through a User Control?
<p>To make certain form creation easier, we use a modified Formview control that is inside a User Control.  This User Control is for a grid and a FormView, you can choose an item in the grid, and a FormView is presented in a modal for viewing/editing:</p>

<pre><code>&lt;I2CL:Grid runat="server" ID="Grid" OnSelecting="Selecting" ShowCreate="true" /&gt;
&lt;I2:Modal ID="SFModal" runat="server" UpdateMode="Conditional"&gt;
 &lt;ContentTemplate&gt;
     &lt;I2:FormView runat="server" ID="FVSubForm" DefaultMode="Edit" DataSourceID="DSSubForm" /&gt;
     &lt;I2:ILDataSource ID="DSSubForm" runat="server" /&gt;
 &lt;/ContentTemplate&gt;
&lt;/I2:Modal&gt;
</code></pre>

<p>In a page, the control looks like this:</p>

<pre><code>&lt;I2C:TabGrid ID="TG" runat="server" Property="ParentProperty"&gt;
  &lt;Columns&gt;
    &lt;I2:Column Header="Column 1" DataSource="Column1" /&gt;
    &lt;I2:Column Header="Column 2" DataSource="Column2" /&gt;
  &lt;/Columns&gt;
  &lt;EditItemTemplate&gt;
    &lt;I2Form:Dropdown ID="Col1" runat="server" SelectedValue='&lt;%# Bind("Column1") %&gt;' List="Column1Options" /&gt;
    &lt;I2Form:Textbox ID="Col2" runat="server" Text='&lt;%# Bind("Column2") %&gt;' /&gt;
  &lt;/EditItemTemplate&gt;
&lt;/I2C:TabGrid&gt;
</code></pre>

<p>The problem is the EditItemTemplate we use.  The only way I can figure out how to hook it up is to have an ITemplate in the TabGrid control and apply the reference in OnInit:</p>

<pre><code>[PersistenceMode(PersistenceMode.InnerProperty), 
 TemplateContainer(typeof(FormView))]
public ITemplate EditItemTemplate { get; set; }

protected override void OnInit(EventArgs e)
{
 base.OnInit(e);
 FVSubForm.EditItemTemplate = EditItemTemplate;
}
</code></pre>

<p>The problem with this is that because the reference is to an object in the user control, the EditItemTemplate reference that ties to the dictionary entries in FormView for changes are destroyed, so when you get the dictionary of changes sent to the datasource, they're empty on every postback.</p>

<p>The I2:ILDataSource used here is a custom implementation closest to ObjectDataSource.  Instead of a generic object call, it directly calls a <code>GetEntity()</code> in the page (or user control in this case) and a <code>UpdateEntity(obj Entity)</code> to save.  Since it's a very specific scenario, we can eliminate 90% of the code in ObjectDataSource.</p>

<p><strong>What I want to be able to do is point the <code>&lt;EditItemTemplate&gt;</code> in the <code>&lt;I2C:TabGrid&gt;</code> directly to the <code>&lt;EditItemTemplate&gt;</code> of the <code>&lt;I2:FormView&gt;</code> inside.</strong>  Is this possible, or anyone have suggestions of another route to go?</p>

<p>Note:  I tried exposing the EditItemTemplate on FVSubForm as a proxy property, but this didn't work because the property is set on the user control before the child control is created, so FVSubForm is null.  If this can be worked around, I'm certainly all ears.</p>
