Note that there are some explanatory texts on larger screens.

plurals
  1. POFormView on a Master Page can't see databound controls through ContentPlaceHolder boundary
    text
    copied!<p>I have a number of similarly structured FormViews. In an effort to avoid duplicate markup, I've created a master page that contains the FormView, and placed a ContentPlaceHolder inside the FormView. The specific databound controls - which are the only thing that change from page to page - are then on the page that uses that master page.</p> <p>So I have a master page that looks something like this:</p> <pre><code>&lt;%@ master ... %&gt; ... &lt;form runat=server&gt; ... &lt;asp:formview runat="server" ... &gt; &lt;edititemtemplate&gt; ... Lots of common markup ... &lt;asp:contentplaceholder id='FormRows' runat='server' /&gt; ... Lots more common markup ... &lt;/edititemtemplate&gt; &lt;/asp:formview&gt; ... &lt;/form&gt; </code></pre> <p>and a page using that master page that looks something like this:</p> <pre><code>&lt;%@ page masterpagefile="Form.Master" ... %&gt; &lt;asp:content contentplaceholderid="FormRows" runat="server" &gt; ... &lt;p&gt; Field One: &lt;asp:textbox runat=server text='&lt;%#Bind("Field1")%&gt;' id='Field1' /&gt; &lt;/p&gt; &lt;p&gt; Field Two: &lt;asp:textbox runat=server text='&lt;%#Bind("Field2")%&gt;' id='Field2' /&gt; &lt;/p&gt; ... &lt;/asp:content&gt; </code></pre> <p>With an existing record, the FormView sees through to the databound controls (Field1, etc) and populates them with the correct data. But when inserting or updating, it doesn't see them, and they're not included in the insert or update. In the <code>FormView_ItemInserting</code> event, <code>e.Values</code> is empty; likewise in the <code>FormView_ItemUpdating</code> event, <code>e.NewValues</code> is empty.</p> <p>So:</p> <ol> <li><p>Is there a way to provoke the FormView on the master page to see through to the databound controls inside the ContentPlaceholder?</p></li> <li><p>Failing that, is there a straightforward way of identifying controls that are databound with <code>&lt;%#Bind(...)%&gt;</code> so that I can add them manually to the values bag?</p></li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload