c# - Copy controls from ItemTemplate -


i'm dealing formview.
have ridiculous long input form, wondering if there's way programmatically copy controls itemtemplate insertitemtemplate/updateitemtemplate don't have repeat text boxes / ddls etc in .aspx since information entered same both update /insert (i know can copy /paste, .aspx messy enough already).

i able set insertitemtemplate = itemtemplate , when set mode insert fields displayed. problem when try findcontrol in submit event null.

you can create user control hold layout. register control in webpage:

<%@ register tagprefix="ctrl" tagname="formcontrol" src="formcontrol.ascx" %> 

and add formview:

<asp:formview id="formview1" runat="server"  datasourceid="objectdatasource1"  allowpaging="true" enableviewstate="false">    <itemtemplate>     <ctrl:formcontrolid="mycontrol1" runat="server" mode="item"/>   </itemtemplate>   <insertitemtemplate>     <ctrl:formcontrolid="mycontrol2" runat="server" mode="insertitem"/>   </insertitemtemplate> </formview> 

i added mode argument because change layout inside control depending on selected mode.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -