title: ASP.NET ListView with identical markup in EditItemTemplate and InsertItemTemplate
body: <p>I have a ListView that includes an EditItemTemplate and an InsertItemTemplate. The two forms share almost all of their markup. For example:</p>
  
  <pre><code>&lt;asp:listview runat="server" ... &gt;
     &lt;layouttemplate&gt;...&lt;/layouttemplate&gt;
     &lt;itemtemplate&gt;
        &lt;p&gt;&lt;%#Eval("Name")%&gt;&lt;/p&gt;
        &lt;p&gt;&lt;%#Eval("Title")%&gt;&lt;/p&gt;
         ...
     &lt;/itemtemplate&gt;
     &lt;insertitemtemplate&gt;
        &lt;p&gt;Name: &lt;asp:textbox runat=server text='&lt;%#Bind("Name")%&gt;' /&gt;&lt;/p&gt;
        &lt;p&gt;Title: &lt;asp:textbox runat=server text='&lt;%#Bind("Title")%&gt;' /&gt;&lt;/p&gt;
        ...
        &lt;asp:button runat=server commandname="Insert" text="Save" /&gt;
     &lt;/insertitemtemplate&gt;
     &lt;edititemtemplate&gt;
        &lt;p&gt;Name: &lt;asp:textbox runat=server text='&lt;%#Bind("Name")%&gt;' /&gt;&lt;/p&gt;
        &lt;p&gt;Title: &lt;asp:textbox runat=server text='&lt;%#Bind("Title")%&gt;' /&gt;&lt;/p&gt;
        ...
        &lt;asp:button runat=server commandname="Update" text="Save" /&gt;
     &lt;/edititemtemplate&gt;
  &lt;/asp:listview&gt;
  </code></pre>
  
  <p>Of course, in reality there's a lot going on in the insert and edit templates (lots of fields, with formatting, validation, etc.), and I hate to have to maintain the same markup twice.</p>
  
  <p>My first thought was to move all the shared markup to a user control (.ascx):</p>
  
  <pre><code>   &lt;insertitemtemplate&gt;
        &lt;custom:myform runat=server /&gt;
        &lt;asp:button runat=server commandname="Insert" text="Save" /&gt;
     &lt;/insertitemtemplate&gt;
     &lt;edititemtemplate&gt;
        &lt;custom:myform runat=server /&gt;
        &lt;asp:button runat=server commandname="Update" text="Save" /&gt;
     &lt;/edititemtemplate&gt;
  </code></pre>
  
  <p>Unfortunately, the two-way binding (text='&lt;%#Bind("Foo")%>') only works one way when the form is in a user control (it doesn't persist the data from the controls back to the database).</p>
  
  <p>An alternative would be to move all the shared markup to an include file. Server-side includes are a throwback to classic ASP, but they still work in ASP.NET and can be useful in situations like this, because the contents of the include file are treated just like markup that's right on the page. </p>
  
  <p>But include files are still a little hokey, and have their disadvantages (e.g. VisualStudio isn't very comfortable with them). Is there an alternative?</p>